module ActiveRecord::Scoping::Default::ClassMethods

Public Instance Methods

default_scope(scope = nil, &block) click to toggle source

Fix for AR 3.2-5.1

# File lib/duty_free.rb, line 264
def default_scope(scope = nil, &block)
  scope = block if block_given?

  if scope.is_a?(Relation) || !scope.respond_to?(:call)
    raise ArgumentError,
          'Support for calling #default_scope without a block is removed. For example instead ' \
          "of `default_scope where(color: 'red')`, please use " \
          "`default_scope { where(color: 'red') }`. (Alternatively you can just redefine " \
          'self.default_scope.)'
  end

  self.default_scopes += [scope]
end