named_scope find options
Let’s say you have
named_scope :red, :conditions => {:color => 'red'}Do not do this:
Shirt.red(:limit => 1) #=> ALL red shirtsYou will get all red shirts. I don’t care how many you limit to, you will get them all. Instead, you need to chain using
find(:all)or it’s aliasall:Shirt.red.all(:limit => 1) #=> ONE red shirtThis has been your Rails public service announcement for 17 September 2008.
Wouldn’t it be easier to do this:?
Shirt.red.first/last