search for: created_by

Displaying 20 results from an estimated 61 matches for "created_by".

Did you mean: created_at
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: http://wiki.rubyonrails.org/rails/pages/Howto+Add+created_by+and+updated_by. It is working fine. The validates_uniquenes...
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 Apr 03
3
Retrieving a record using created_by
Hello, Thank you all in advance for your help with this. Environment: Windows XP Pro (Development only) Ruby 1.84 Rails 1.1.0 SaltedHashLoginGenerator Plugins: file_column, userstamp I have a user table per the salted_hash_login generator. I have an orders table that has a column named created_by that is updated by the userstamp plugin. I am trying to retrieve all of the orders for a single user (the one logged in) and am not sure how to do it. When I use this code in my order model it works: def self.my_orders find(:all, :conditions => "created_by = 1",...
2006 Jan 20
11
Userstamp Plugin
...delynn@gmail.com http://www.delynnberry.com A dump of the Readme file is contained below -- Userstamp Plugin (v 1.0) ======================== Overview -------- The Userstamp Plugin extends ActiveRecord::Base( http://api.rubyonrails.com/classes/ActiveRecord/Base.html) to add automatic updating of created_by and updated_by attributes of your models in much the same way that the ActiveRecord::Timestamp( http://api.rubyonrails.com/classes/ActiveRecord/Timestamp.html) module updates created_(at/on) and updated_(at/on) attributes. The module requires that your application''s user object (User by d...
2006 Apr 11
5
Multiple "has" in ActiveRecord
...ss/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 table like this: create table log ( id serial8 primary key ,created_by int8 references people(id) ,created_for int8 references people(id) ); Now, in my Model class, how do I handle this? class Log < ActiveRecord::Base has_one :People end Is there some way to differentiate the two different has_one references but keep them looking at the same table? Tha...
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 self.created_by = get_user() end I had trouble getting the assignment to work. I initially tried simply created_by = get_user() (no ''self'') I don'...
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 for the others. Is there a recommendation for this kind of situation? Plurality in Classes: Not in class names as much as in the part where you say belongs_to, has...
2007 May 06
5
Comparing polymorphic property to same object fails
...s 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 == self.created_by self.activated_at = Time.now self.activation_code = nil end fails to detect equality correctly. I''ve tried ===, eql? etc. When I look at .__id__ when I know that I set assignable equal to created_by, the values are different (wildly so; one is like 4 and the other is a fi...
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 m...
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 it''s because I can''t get a class method...
2006 Jan 16
0
belongs_to with has_and_belongs_to_many
...to_many. Here''s a brief summary of the models involved: class Member < ActiveRecord::Base set_primary_key ''member_id'' has_and_belongs_to_many :projects, :join_table => ''projects__members'' has_many :projects, :foreign_key => ''created_by'' end class Project < ActiveRecord::Base set_primary_key ''project_id'' belongs_to :created_by, :class_name => ''Member'', :foreign_key => ''created_by'' has_and_belongs_to_many :members, :join_table => ''projec...
2007 Aug 03
0
acts_as_paranoid and Association Extensions (has_one troubles)
...pment environment. >> sc = SportClub.find_with_deleted(7) => #<SportClub:0xb769c1a4 @attributes={"number_of_members"=>nil, "name"=>"Maastricht Wildcats", "updated_at"=>"2007-08-03 21:50:44", "deleted_at"=>nil, "created_by"=>nil, "organization_code"=>"KNVB347", "url"=>nil, "type"=>"SportClub", "updated_by"=>nil, "id"=>"7", "description"=>"", "deleted_by"=>nil, "created_at&quo...
2006 Jul 23
4
has_many AND has_many :through ?
Hi, I am working on a scheduling app and I have a perpelextion (new word). I am wondering if the problem is my data model I have Users. Users can create Events. Users can be invited to Events created by other Users. So... user.rb class User < ActiveRecord::Base has_many :invitations # invitations to other users'' events has_many :events, :through => :invitations # all events
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 = ?'', tr...
2005 Feb 07
0
Trying to Seed Maybe Bug?
...uot;=>"Blah!", "announce"=>"http://localhost:6969"}, @s= #<RubyTorrent::TypedStruct:0x10a3140 @array= {:announce_list=>true, :creation_date=>false, :info=>false, :comment=>false, :announce=>false, :created_by=>false, :encoding=>false}, @coerce= {:announce_list=> #<Proc:0x00074ba0@./3rdParty/rubytorrent/rubytorrent/metainfo.rb:144>, :creation_date=> #<Proc:0x00074ee8@./3rdParty/rubytorrent/rubytorrent/metainfo.rb:142>, :info=>...
2011 Nov 18
1
What does :count actually mean in assert_select?
...9;'m using Rspec2. Example: spec/factories/categories.rb ====================== FactoryGirl.define do factory :category_intakes, :class => ''category'' do name ''intakes and filters'' description ''airfilters and etc.'' created_by 1 updated_by 1 end factory :category_audio, :class => ''category'' do name ''audio'' description ''in car entertainment'' created_by 1 updated_by 1 end end spec/views/categories/index.html.erb ================...
2006 Mar 26
5
How to write manage created_on and created_by via mixin?
...ever, I hold out hope - I just don''t know the terminology for what I''m looking for since what I''m doing has to be relatively common. So, I''ve created a mixin called UserTimestamp.rb: module UserTimestamp def mark_created self.created_on = Time.new self.created_by = @user.user_id end def mark_updated self.updated_on = Time.new self.updated_by = @user.user_id end end And, then I include it and setup the before_create and after_create macros: require ''lib/UserTimestamp.rb'' class Video < ActiveRecord::Base include UserTim...
2006 Feb 18
5
Date formatting error
...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 note.created_by %> <% end %> Which gives me the error... |"You have a nil object when you didn''t expect it! The error occured while evaluating nil.strftime" When I remove the |.strftime("%I:%M") from note.created_at the display works correctly showing the data with the de...
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 sd_ticket=self.find(sd_id) sd_ticket.service...
2006 May 23
1
Validating a required relationship.
Hello, I''m not sure if I''m missing something blindingly obvious here. All the relationships that Rails comes with assume 0..n, yes? It''s not a strict 1 to 1 or 1 to n because it''s optional. My question is this - What is the best way to implement a required relationship? For example, if I require that a comment is made by a user (a user has many