In the old days, we did this:
User.find(:all, :conditions => { :subscribed => true }, :order => 'created_at DESC' )
And then this:
User.find_all_by_subscribed(true, :order => 'created_at DESC' )
How about this?
User.for_subscribed(true).order_by('created_at DESC').find(:all)
Here’s the how!
class User < ActiveRecord::Base
named_scope_for :subscribed
end
Whup-cha!
class ActiveRecord::Base
def self.named_scope_for attribute
named_scope "for_#{attribute}",
lambda { |attribute_value| [...]