Revert "Revert "Merge pull request #10901 from armstrjare/fix_query_null_foreign_key_on_new_record_collection_ids_reader""

This reverts commit 5009b07887.

Also updated the CHANGELOG and adjusted the test-case to match the one on master.
This commit is contained in:
Yves Senn
2013-06-25 18:07:06 +02:00
parent b0c65978ab
commit 27b3883846
3 changed files with 43 additions and 1 deletions

View File

@@ -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