Displaying 20 results from an estimated 700 matches similar to: "Retrieving a record using created_by"
2006 Jan 20
11
Userstamp Plugin
I''m pleased to announce a new plugin for Rails: Userstamp. You can read my
blog post at http://www.delynnberry.com/articles/2006/01/20/userstamp-plugin
and/or read all about it at the perminant page
http://www.delynnberry.com/pages/userstamp. Any comments or suggestions for
improvement are much appreciated.
--
DeLynn Berry
delynn@gmail.com
http://www.delynnberry.com
A dump of the Readme
2006 Sep 09
13
best way to add "created_by" entries to all tables???
Hi,
I want to automate somewhat the addition of created_by/updated_by fields
on my models (i.e. to include username). What''s the best/recommended
way to do this? Would it be to:
a) Find out how to extend the ActiveRecord::Base itself (I haven''t
extended a class before yet)
b) Use a plugin type approach where you have to add a tag manually to
each model file which then
2006 Dec 06
2
validates_uniqueness_of where scope euqals created_by "magic" field
I have the following ActiveRecord objects:
class Recipe < ActiveRecord::Base
has_many :ratings, :dependent => true
. . .
end
class Rating < ActiveRecord::Base
validates_uniqueness_of :created_by, :scope => :recipe_id
belongs_to :recipe, :counter_cache => true
. . .
end
The created_by field on Rating is implemented as a "magic" field
similar to this:
2009 Oct 20
0
Userstamp plugin doesn't load in "test" environment - y not?
I''m working on an app. with the userstamp plugin in it (from 2 - 3 years
back).
In the init.rb file, there''s this:
ActiveRecord::Base.send(:include, ActiveRecord::Userstamp) unless
RAILS_ENV == ''test''
This causes certain tests to fail since created_by is a required
attribute.
Does anyone know the idea behind Userstamp not loading in the test
environment.
2006 Mar 26
5
How to write manage created_on and created_by via mixin?
Hi!
Definite newbie here - I''m working through this like-hate relationship with
Ruby and Rails right now... sometimes things work really well (like blobs
seem to rock) but other times, I dunno! :-)
Anyway, I''d like put in create and update user timestamps on all my primary
domain tables and allow them to be updated automatically by ActiveRecord.
Coming from Hibernate, I just
2006 Sep 09
2
why doesn't this work (setting attribute in "before_create")
Hi,
Can anyone spot why the below doesn''t work?
* I have a "created_by" column in my create table in the dB
* I have a "before_create" line, which definitely gets called
* I tried a few different ways to set the "created_by" attribute in the
model but it doesn''t seem to work, i.e. doesn''t appear in the database
2006 Jul 18
1
usermonitor / user stamping active record
Quick question about userstamping records in a similar way to
timestamping. There is an example of how this might work at:
http://wiki.rubyonrails.org/rails/pages/Howto+Add+created_by+and+updated_by/versions/7
This seems to work fine on my development system. However, I am not
sure how the User.current_user method, which is required, can guarantee
to return the correct user since this is a
2006 Jan 03
2
help me understand association attributes
I have a model with a belongs_to association. The first model is called
Thing and the associated model is User. I''m attempting to assign the user to
the thing.
To accomplish this I used a before_save method, like this:
class Thing < ActiveRecord::Base
belongs_to :created_by, :class_name => "User", :foreign_key =>
"created_by_user_id"
def before_create
2005 Aug 09
3
Adding created_by and updated_by trouble
Hi everyone. This is a real noob question that I''m hoping someone out there
can help me with.
I have followed the tutorial How to Ad created_by and
updated_b<http://wiki.rubyonrails.com/rails/show/Howto%20Add%20created_by%20and%20updated_by>y
and it works ok for retrieving the data. I''m using the Login_Generator.
I cannot get it to work on create or update. I think
2006 Apr 12
0
class attributes and thread safety
Are class attributes thread safe? For instance, the userstamp plugin
creates a User.current_user attribute and then it aliases the
ActiveRecard create and update methods to write created_by and
updated_by attributes using the value of User.current_user. For some
reason I can imagine a case where multiple users are logged in at the
same time and saving objects, and the value of
2007 May 06
5
Comparing polymorphic property to same object fails
I''ve got a polymorphic association on one table. I assign to it in the
controller.
This is handling invitations of users to tasks in a task management
application. If the user issuing the invitation is the user being
invited (ie the user assigned themselves to a task), I want to
activate the invitation immediately in the model.
The trouble is that this:
if self.assignable ==
2007 May 20
1
beating a dead horse - proper association selection
okay... i have two models
employee
- id
- username
order
- id
- number
- created_by
- approved_by
now created_by and approved_by are both id''s of employees. in most
cases, two different employees.
currently i do something like
//controller
@open_orders = Order.open_orders
//model
def self.open_orders
find(:all, :conditions => [''is_open = ?'', true],
2006 Feb 26
3
Rails Naming Conventions
DB field names:
If I have a table that references 2 or more separate users from my users
table, is there a recommended naming convention for this situation? In
my case, I have 3 users associated with a record in my projects table:
requester_user_id
created_by
updated_by
I could name one of them "user_id", and then projects.user would work I
guess, but wouldn''t work
2006 Apr 11
5
Multiple "has" in ActiveRecord
Please excuse a newbie question, but I couldn''t find anything by
searching the archives.
What I want to know is how to have multiple references to the same
class/table within a class. For example, let''s say I have a table called
People:
create table people (
id serial8 primary key
,name);
which just holds a list of the people in the database. Then I have
another
2011 Nov 18
1
What does :count actually mean in assert_select?
Hi guys,
I tried reading up the RSPEC Book (Dec 2010) and googled a bit but I
could not find anything.
I''m using Rspec2.
Example:
spec/factories/categories.rb
======================
FactoryGirl.define do
factory :category_intakes, :class => ''category'' do
name ''intakes and filters''
description ''airfilters and
2008 Sep 25
1
question about exception
Hi
In the controller I have the function
def convert_sd_ticket_to_incident
ServiceDeskTicket.close_ticket(sd_id,created_by_id,modified_by_id)
Incident.convert_sd_ticket_to_incident(sd_id,created_by_id,modified_by_id)
end
Now in the ServiceDeskTicket model
def self.close_ticket(sd_id,created_by,modified_by)
begin
ActiveRecord::Base.transaction do
2006 Feb 14
10
acts_as_versioned and getting authors
Hey guys and gals,
I have the following object that has acts_as_versioned:
class Note < ActiveRecord::Base
acts_as_versioned
belongs_to :user
end
The schema for my notes table is as follows:
create_table :notes, :force => true do |t|
t.column :id, :integer
t.column :noteshare_id, :integer
t.column :user_id, :integer
t.column :title, :string
2006 Feb 18
5
Date formatting error
Hi All,
I''m a bit stumped. All I''m trying to do is format a date and I get an
error. Details below.
I have a partial to list all "notes" associated with a "client" with the
following code.
<% for note in @client.notes %>
<hr />
<%=h note.note_text %>
Posted on <%=h note.created_at.strftime("%I:%M") %> by <%=h
2008 Mar 28
6
Eager Loading + Confusion
So I''m trying to do a find with an order by specific column values
thing, but some of the columns are attributes through associations.
So I did some eager loading with the :include option to try and access
the attributes of the object I''m doing the find on. Stuff has been
blowing up on me so far.
Here''s the code in the controller right now:
sort_by = params[:sort_by]
2009 Jan 13
1
ROR - Excel Export Example
If you are running on Windows you can use create and read speadsheets
using the ''win32ole'' require
This sample should give you the basic idea
------
def export
require ''win32ole''
@sort_by = ''last_name''
current_user = ''steve''
@records = Contact.find(
:all,
:conditions =>