aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-01-24 17:54:10 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-01-24 17:54:10 +0000
commitfe6ffce51dc16285094be49244b26591956c2dd6 (patch)
treef83e9fb9cde96e2e5b5d2e89ea9ae0333d2f0b9b /activerecord/lib
parentb2192888ab28b4cc36a54b5c918c6773de95a030 (diff)
downloadrails-fe6ffce51dc16285094be49244b26591956c2dd6.tar.gz
rails-fe6ffce51dc16285094be49244b26591956c2dd6.tar.bz2
rails-fe6ffce51dc16285094be49244b26591956c2dd6.zip
Make sure inner scope conditions get a preference over the outer ones
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/base.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index ebc0b7783f..8db3909d9a 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2097,7 +2097,11 @@ module ActiveRecord #:nodoc:
(hash[method].keys + params.keys).uniq.each do |key|
merge = hash[method][key] && params[key] # merge if both scopes have the same key
if key == :conditions && merge
- hash[method][key] = merge_conditions(params[key], hash[method][key])
+ if params[key].is_a?(Hash) && hash[method][key].is_a?(Hash)
+ hash[method][key] = merge_conditions(hash[method][key].deep_merge(params[key]))
+ else
+ hash[method][key] = merge_conditions(params[key], hash[method][key])
+ end
elsif key == :include && merge
hash[method][key] = merge_includes(hash[method][key], params[key]).uniq
elsif key == :joins && merge
@@ -2107,7 +2111,7 @@ module ActiveRecord #:nodoc:
end
end
else
- hash[method] = params.merge(hash[method])
+ hash[method] = hash[method].merge(params)
end
else
hash[method] = params