class method self.included

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

self.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.

Parameters

base req
Source
# File activerecord/lib/active_record/named_scope.rb, line 9
    def self.included(base)
      base.class_eval do
        extend ClassMethods
        named_scope :scoped, lambda { |scope| scope }
      end
    end

Defined in activerecord/lib/active_record/named_scope.rb line 9 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::NamedScope

Type at least 2 characters to search.

↑↓ navigate · open · esc close