aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-06 17:33:25 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-06 17:51:48 -0200
commite26fa7b9216443c4dfcb887694afbefa70a9e450 (patch)
tree7fc9df4843621ac4a33d582e500a42ff9f2f8d9e /activerecord/lib
parentdecb7b66d040eafbbf03e4533672eb135d49a036 (diff)
downloadrails-e26fa7b9216443c4dfcb887694afbefa70a9e450.tar.gz
rails-e26fa7b9216443c4dfcb887694afbefa70a9e450.tar.bz2
rails-e26fa7b9216443c4dfcb887694afbefa70a9e450.zip
Stoping using Relation#merge in default_scoped
Relation#merge checks if the argument is an array and the only possible returns of build_default_scope is nil or a Relation. Doing this we can raise an ArgumentError when Relation#merge receive a nil value.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 35420e6551..a083deafe1 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -30,7 +30,13 @@ module ActiveRecord
end
def default_scoped # :nodoc:
- relation.merge(build_default_scope)
+ scope = build_default_scope
+
+ if scope
+ relation.spawn.merge!(scope)
+ else
+ relation
+ end
end
# Collects attributes from scopes that should be applied when creating