Displaying 4 results from an estimated 4 matches for "find_or_create_by_".
Did you mean:
find_or_create_by
2008 Feb 07
1
ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
....find_by_user_name is actually
Person.find_by_user_name(user_name, options). So you could call
Payment.find_all_by_amount(50, :order => "created_on").
The same dynamic finder style can be used 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...
2012 Jul 24
4
Behavior of first_or_create
I just ran across a weird glitch (IMHO) in find_or_create. The arguments passed to it are *not* added to the conditions for the ''first'' part. This is odd, given that it''s intended to replace find_or_create_by_* methods, which *did* use the specified values as conditions.
I''m unsure on whether this behavior is entirely undesirable, but it''s definitely not what I had expected in my use case (ensuring that a join table record exists). Perhaps there should be a variant (find_or_create_exac...
2010 Jun 25
3
Best practice for removing leading and trailing whitespaces
I want to remove the leading and training spaces for most of the
resources in my rails application
For a new POST request, rails does the xml parsing and passes the params
hash to the controller. Some of the parameters have leading and/or
trailing whitespaces which are causing problems (e.g. new resources
being created rather than using the old ones). I don''t want to put the
code in all
2008 Feb 08
4
x-post : find_or_initialize_by ActiveRecord bug? Ignores :conditions
....find_by_user_name is actually
Person.find_by_user_name(user_name, options). So you could call
Payment.find_all_by_amount(50, :order => "created_on").
The same dynamic finder style can be used 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 o...