= XlSuite::AutoScope Automatically create scoped access methods on your ActiveRecord models. == Examples Declare your scopes within your ActiveRecord::Base subclasses. 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 These declarations give you access to the following scoped methods: Testimonial.approved.count Testimonial.unapproved.create!(params[:testimonial]) @young_contacts = Contact.young @contacts = Contact.old.find(:all, :conditions => ["name LIKE ?", params[:name]]) = More Information Blog: http://blog.teksol.info/articles/2007/03/28/autoscope-plugin-automatic-scopes-for-your-needs Plugin home: http://xlsuite.org/plugins/auto_scope Subversion: http://svn.xlsuite.org/plugins/auto_scope/ Enjoy ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---