aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-12-31 21:53:19 +0100
committerGitHub <noreply@github.com>2016-12-31 21:53:19 +0100
commit334a7dcf107cd3ff1697163d331d289d6d65dcd7 (patch)
tree7dbe7486207793862f391a7afa42cf1096cb30ba
parentac0b28883b78999c5605d032eb42fcd842841e6b (diff)
parent6ba7adbaa76244e9e592f5672c8411dd0b4e7fce (diff)
downloadrails-334a7dcf107cd3ff1697163d331d289d6d65dcd7.tar.gz
rails-334a7dcf107cd3ff1697163d331d289d6d65dcd7.tar.bz2
rails-334a7dcf107cd3ff1697163d331d289d6d65dcd7.zip
Merge pull request #27529 from kamipo/refactor_ids_reader
Refactor `CollectionAssociation#ids_reader`
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 974405e019..9fa8b5d469 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -47,9 +47,7 @@ module ActiveRecord
# Implements the ids reader method, e.g. foo.item_ids for Foo.has_many :items
def ids_reader
if loaded?
- load_target.map do |record|
- record.send(reflection.association_primary_key)
- end
+ target.pluck(reflection.association_primary_key)
else
@association_ids ||= (
column = "#{reflection.quoted_table_name}.#{reflection.association_primary_key}"