class method self.default_scope

Ruby on Rails 2.3.18

Since v2.3.18 Last seen in v3.1.12

Available in: v2.3.18 v3.0.20 v3.1.12

Signature

self.default_scope(options = {})

Sets the default options for the model. The format of the options argument is the same as in find.

class Person < ActiveRecord::Base
  default_scope :order => 'last_name, first_name'
end

Parameters

options opt = {}
Source
# File activerecord/lib/active_record/base.rb, line 2208
        def default_scope(options = {})
          self.default_scoping << { :find => options, :create => options[:conditions].is_a?(Hash) ? options[:conditions] : {} }
        end

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

Defined in ActiveRecord::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close