From 40e87ac66912b06c31c98b057a49c64f5555dd99 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Mon, 28 Jun 2010 17:17:56 -0400 Subject: with_exclusive_scope does not work properly if ARel is passed. It does work nicely if hash is passed. Blow up if user is attempting it pass ARel to with_exclusive_scope. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#3838 state:resolved] Signed-off-by: José Valim --- activerecord/lib/active_record/base.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index fa239bafc6..8c10f86486 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1156,7 +1156,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 + + 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) + end with_scope(method_scoping, :overwrite, &block) end -- cgit v1.2.3