Ruby on Rails: Quick tip for Find :conditions
January 11th, 2008 I stumbled across a sneaky tip for conditions when using find. When you might normally be doing this:
1 2 |
Account.find(:all, :conditions => ['name LIKE ? AND updated_at < ?', "aname", 3.days.ago]) |
1 2 |
Account.find(:all, :conditions => ['name LIKE :name AND updated_at < :date', {:name => "aname", :date => 3.days.ago}]) |
This isn't the best example of using this symbol placeholder method, but imagine using it in a situation where you're repeating the same search param a few times. I know I've had a few times that my conditions has been something like
1 2 |
['created_at > ? AND updated_at < ? AND invoiced_at > ?'], Time.now, Time.now, Time.now]. |
Update: See ActiveRecord::Base on Noobkit for more info

Feed me
