aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/base.rb21
-rw-r--r--activerecord/lib/active_record/relation.rb2
2 files changed, 12 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index c0ded7f558..b44158ec75 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -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
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 3b24d4aafd..bc708b573f 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -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)