aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/collection_association.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-03-18 11:20:47 +0100
committerYves Senn <yves.senn@gmail.com>2015-03-18 11:20:47 +0100
commit08615a3bcbe57b99881f6f3f5b649ed413b9307b (patch)
tree47e67d2849eed62d520c0deccd24eefbe46f7305 /activerecord/lib/active_record/associations/collection_association.rb
parent848680015bca5704bb17be79948ce68d77e71f54 (diff)
parentc82cc222c793275f74fc5e8b6aa88edebe136929 (diff)
downloadrails-08615a3bcbe57b99881f6f3f5b649ed413b9307b.tar.gz
rails-08615a3bcbe57b99881f6f3f5b649ed413b9307b.tar.bz2
rails-08615a3bcbe57b99881f6f3f5b649ed413b9307b.zip
Merge pull request #19348 from Empact/null-scope
Reuse the CollectionAssociation#reader proxy cache if the foreign key is present from the start. Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/associations/collection_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 1e245926e0..88531205a1 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -33,10 +33,10 @@ module ActiveRecord
reload
end
- if owner.new_record?
+ if null_scope?
# Cache the proxy separately before the owner has an id
# or else a post-save proxy will still lack the id
- @new_record_proxy ||= CollectionProxy.create(klass, self)
+ @null_proxy ||= CollectionProxy.create(klass, self)
else
@proxy ||= CollectionProxy.create(klass, self)
end