Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- named_scope :unverified, :conditions => {:verified => false}
- # This makes a named_scope as desired, but duplicates the code in unverified.
- named_scope :inactive, lambda {{ :conditions => ["verified = ? and last_login < ?", false, Time.now - 3.months] } }
- # We can avoid the duplication with an explicit method. Can't we do this in a named_scope directly?
- def self.inactive2
- self.unverified.find(:all, :conditions => ["last_login < ?", Time.now - 3. months])
- end
- # e.g.... (but this does not work, natch)
- named_scope :inactiv3, lambda { User.inactive + { :conditions => ["last_login < ?", Time.now - 3. months] } }
Add Comment
Please, Sign In to add comment