Module: CollectiveIdea::NamedScope
- Defined in:
- vendor/plugins/awesome_nested_set/lib/awesome_nested_set/named_scope.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods Classes: Scope
Class Method Summary
-
+ (Object) included(base)
All subclasses of ActiveRecord::Base have two named_scopes:
- all, which is similar to a find(:all) query, and
- scoped, which allows for the creation of anonymous scopes, on the fly:.
Class Method Details
+ (Object) included(base)
All subclasses of ActiveRecord::Base have two named_scopes:
- all, which is similar to a find(:all) query, and
- 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.
12 13 14 15 16 17 |
# File 'vendor/plugins/awesome_nested_set/lib/awesome_nested_set/named_scope.rb', line 12 def self.included(base) base.class_eval do extend ClassMethods named_scope :scoped, lambda { |scope| scope } end end |