mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Tidy up deprecation message for with_exclusive_scope.
This commit is contained in:
parent
bd1666ad1d
commit
417125e795
2 changed files with 12 additions and 11 deletions
|
@ -1181,19 +1181,20 @@ module ActiveRecord #:nodoc:
|
|||
end
|
||||
|
||||
# Works like with_scope, but discards any nested properties.
|
||||
# TODO : this method should be deprecated in favor of standard query API
|
||||
def with_exclusive_scope(method_scoping = {}, &block)
|
||||
if method_scoping.values.any? { |e| e.is_a?(ActiveRecord::Relation) }
|
||||
msg =<<-MSG
|
||||
ARel can not be used with_exclusive_scope. You can either specify hash style conditions to with_exclusive_scope like this:
|
||||
User.with_exclusive_scope {:find => :conditions => {:active => true} } do
|
||||
end
|
||||
raise ArgumentError, <<-MSG
|
||||
New finder API can not be used with_exclusive_scope. You can either call unscoped to get an anonymous scope not bound to the default_scope:
|
||||
|
||||
Or you can use unscoped method instead of with_exclusive_scope like this:
|
||||
User.unscoped.where(:active => true) do
|
||||
end
|
||||
MSG
|
||||
raise ArgumentError.new(msg)
|
||||
User.unscoped.where(:active => true)
|
||||
|
||||
Or call unscoped with a block:
|
||||
|
||||
User.unscoped do
|
||||
User.where(:active => true).all
|
||||
end
|
||||
|
||||
MSG
|
||||
end
|
||||
with_scope(method_scoping, :overwrite, &block)
|
||||
end
|
||||
|
|
|
@ -352,7 +352,7 @@ module ActiveRecord
|
|||
elsif @klass.scopes[method]
|
||||
merge(@klass.send(method, *args, &block))
|
||||
elsif @klass.respond_to?(method)
|
||||
@klass.send(:with_scope, self) { @klass.send(method, *args, &block) }
|
||||
scoping { @klass.send(method, *args, &block) }
|
||||
elsif arel.respond_to?(method)
|
||||
arel.send(method, *args, &block)
|
||||
elsif match = DynamicFinderMatch.match(method)
|
||||
|
|
Loading…
Reference in a new issue