aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/scoping
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-05-28 10:12:18 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-05-28 10:12:18 +0900
commitd1249c1a91df614ceb10167155b0265b9578835e (patch)
tree00f3ab8fd123aeddf3333d59f712040dad2906c3 /activerecord/lib/active_record/scoping
parentc45c9cfb011fce54c319555c8852d915ff2ef97a (diff)
downloadrails-d1249c1a91df614ceb10167155b0265b9578835e.tar.gz
rails-d1249c1a91df614ceb10167155b0265b9578835e.tar.bz2
rails-d1249c1a91df614ceb10167155b0265b9578835e.zip
Refactor `default_scoped` to avoid creating extra relation and merging
Diffstat (limited to 'activerecord/lib/active_record/scoping')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 27cdf8cb7e..d03c23fe5c 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -30,13 +30,8 @@ module ActiveRecord
end
def default_scoped # :nodoc:
- scope = build_default_scope
-
- if scope
- relation.spawn.merge!(scope)
- else
- relation
- end
+ scope = relation
+ build_default_scope(scope) || scope
end
# Adds a class method for retrieving and querying objects.