method
unscope!
v6.1.3.1 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
unscope!(*args)public
No documentation available.
# File activerecord/lib/active_record/relation/query_methods.rb, line 432
def unscope!(*args) # :nodoc:
self.unscope_values += args
args.each do |scope|
case scope
when Symbol
scope = :left_outer_joins if scope == :left_joins
if !VALID_UNSCOPING_VALUES.include?(scope)
raise ArgumentError, "Called unscope() with invalid unscoping argument ':#{scope}'. Valid arguments are :#{VALID_UNSCOPING_VALUES.to_a.join(", :")}."
end
assert_mutability!
@values.delete(scope)
when Hash
scope.each do |key, target_value|
if key != :where
raise ArgumentError, "Hash arguments in .unscope(*args) must have :where as the key."
end
target_values = resolve_arel_attributes(Array.wrap(target_value))
self.where_clause = where_clause.except(*target_values)
end
else
raise ArgumentError, "Unrecognized scoping: #{args.inspect}. Use .unscope(where: :attribute_name) or .unscope(:order), for example."
end
end
self
end