According to changeset 4425 find just got a bit of an update. You can now pass in a hash to the condition parameter and it will be converted to an AND-based condition string.

The following …

Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2)

is now the same as …

Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2)

Leave a Reply


(textile enabled)