rails/rails — Issue #4306: Unscoped Scope
Author: sethvargo
Created: 2012-01-04 22:15:25+00:00
State: open

There doesn't seem to be a way to define a scope that ignores any existing scopes, unless using a class method:

# works
def self.inactive
unscoped { where(:is_active => false) }
end

# none of these work
scope :inactive, unscoped { where(:is_active => false) }
scope :inactive, with_exclusive_scope { where(:is_active => true) }
scope :inactive, unscoped.where(:is_active => false)
scope :inactive, lambda { unscoped { where(:is_active => false) } }
scope :inactive, unscoped { lambda { where(:is_active => false) } }
unscoped do
scope :inactive, where(:is_active => false)
end