Plugins - ScopedProxy
Add to favoritesScopedProxy uses with_scope and proxy objects to make it easy to find and count different types of records.
Examples
class Person < ActiveRecord::Base scoped_proxy :minor, :conditions => 'age <= 17' scoped_proxy :adult, :conditions => 'age >= 18' scoped_proxy :old, :conditions => 'age >= 70' scoped_proxy :male, :conditions => 'gender = "male"' scoped_proxy :female, :conditions => 'gender = "female"' scoped_proxy :single, :conditions => 'married = 0' scoped_proxy :married, :conditions => 'married = 1' end Person.adult.find :all Person.single.find :all
They can also be chained together.
Person.single.female.find :all Person.old.male.count
