aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJared Armstrong <jared.armstrong@gmail.com>2013-06-10 15:45:58 +1200
committerJared Armstrong <jared.armstrong@gmail.com>2013-06-21 13:03:54 +1200
commitc2377f72d2c7df1103eac73b0eb3781c02ef2e18 (patch)
treea752e2d1c313d2c797e85b4408d62db5e5031a91 /activerecord/lib/active_record
parentf42e0fd3f4d3e2f4b806b001b6ed88c8da8cd833 (diff)
downloadrails-c2377f72d2c7df1103eac73b0eb3781c02ef2e18.tar.gz
rails-c2377f72d2c7df1103eac73b0eb3781c02ef2e18.tar.bz2
rails-c2377f72d2c7df1103eac73b0eb3781c02ef2e18.zip
Fixes CollectionAssociation#ids_reader returning incorrect ids for new records
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 65e882867e..baddb9852f 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -43,7 +43,7 @@ module ActiveRecord
# Implements the ids reader method, e.g. foo.item_ids for Foo.has_many :items
def ids_reader
- if loaded? || options[:finder_sql]
+ if owner.new_record? || loaded? || options[:finder_sql]
load_target.map do |record|
record.send(reflection.association_primary_key)
end