aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-06-29 17:42:20 +0200
committerJosé Valim <jose.valim@gmail.com>2010-06-29 17:42:20 +0200
commit417125e7955e56159524992b0e95e92d2f7bf0cb (patch)
treeb8b9bde167dd34555357c20bc723252872dd9179 /activerecord/lib/active_record
parentbd1666ad1de88598ed6f04ceffb8488a77be4385 (diff)
downloadrails-417125e7955e56159524992b0e95e92d2f7bf0cb.tar.gz
rails-417125e7955e56159524992b0e95e92d2f7bf0cb.tar.bz2
rails-417125e7955e56159524992b0e95e92d2f7bf0cb.zip
Tidy up deprecation message for with_exclusive_scope.
Diffstat (limited to 'activerecord/lib/active_record')
-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)