Methods
Classes and Modules
Module ActiveRecord::NamedScope::ClassMethodsClass ActiveRecord::NamedScope::Scope
Public Class methods
All subclasses of ActiveRecord::Base have one named scope:
- scoped - which allows for the creation of anonymous \scopes, on the fly: Shirt.scoped(:conditions => {:color => ‘red’}).scoped(:include => :washing_instructions)
These anonymous \scopes tend to be useful when procedurally generating complex queries, where passing intermediate values (scopes) around as first-class objects is convenient.
You can define a scope that applies to all finders using ActiveRecord::Base.default_scope.
[ show source ]
# File activerecord/lib/active_record/named_scope.rb, line 10 10: def self.included(base) 11: base.class_eval do 12: extend ClassMethods 13: named_scope :scoped, lambda { |scope| scope } 14: end 15: end