Displaying 2 results from an estimated 2 matches for "find_or_initialize_by_name_and_st".
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.gmane.org...
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/rubyonrails-tal...