auto_scope

source: http://blog.teksol.info/archives/2007/3

class Contact < ActiveRecord::Base
auto_scope \
:old => {:find => {:conditions => [born_on < ?, 30.years.ago]}},
:young => {:find => {:conditions => [born_on > ?, 1.year.ago]}}
end

class Testimonial < ActiveRecord::Base
auto_scope \
:approved => {
:find => {:conditions => [approved_at < ?, proc {Time.now}]},
:create => {:approved_at => proc {Time.now}}},
:unapproved => {
:find => {:conditions => approved_at IS NULL},
:create => {:approved_at => nil}}
end

Rails internals!?

http://localhost:3000/rails/info/properties

Threads