ScopedProxy uses with_scope and proxy objects to make it easy to find
count different types of records.
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’
They can also be chained together.
They can be used directly as shown above or the scoped proxy object
be stored and passed to methods expecting an ActiveRecord object with
find and count capabilities.
single_female_finder = Person.single.female