search for: find_or_initialize_by

Displaying 3 results from an estimated 3 matches for "find_or_initialize_by".

2006 Oct 21
0
find_or_initialize_by and Nested Resources
Hey guys, Lets say I have the following nested resources: map.resource artists do |artists| map.resource songs end To create a new song, the url would be: /artists/:artist_id/songs/:song_id However, lets say that an artist doesn''t exist yet. I only want to create an artist if a new song by the artist is successfully saved. I am retrieving the artist using something like: @artist
2008 Feb 07
1
ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
...to create the object if it doesn''t already exist. This dynamic finder is called with find_or_create_by_ and will return the object if it already exists and otherwise creates it, then returns it." Here are a couple of examples. I know these are contrived since I could use ''find_or_initialize_by_name_and_state()'' however what I am really trying to show is that the :conditions options are ignored. Check out the actual SQL run by each of these finds in a console to see what I mean. ## EXAMPLE : USES CONDITIONS ## >> @user = User.find_by_email(''foo-+RB1Aph5k6s@public...
2008 Feb 08
4
x-post : find_or_initialize_by ActiveRecord bug? Ignores :conditions
...d to create the object if it doesn''t already exist. This dynamic finder is called with find_or_create_by_ and will return the object if it already exists and otherwise creates it, then returns it." Here are a couple of examples. I know these are contrived since I could use ''find_or_initialize_by_name_and_state()'' however what I am really trying to show is that the :conditions options are ignored. Check out the actual SQL run by each of these finds in a console to see what I mean. PASTIE w/ examples: http://pastie.caboo.se/148479 Original Post: http://groups.google.com/group/rub...