I’ve just discovered the “named_scope” method which seems great. I’m wondering there is any reason why you wouldn’t always use a named scope (to get the advantages), over a custom method on your model to return an array of records?
That is using:
class Shirt < ActiveRecord::Base
named_scope :red, :conditions => {:color => 'red'}
end
instead of
class Shirt < ActiveRecord::Base
def red
Shirt.find_all_by_color('red')
end
end
The only reason to use a custom method instead of a named_scope is when you’re doing more than querying the db or there’s something named_scopes can’t handle.
ok - so if you had the time, updating all your custom finder methods to named_scope would give you more flexibility then. I was just wanting to check if there were any negatives or gotchas to named_scope’s