From df0765d8dc013ccd399d994109eaf39be4c24e81 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sun, 28 Oct 2007 03:39:18 +0000 Subject: Make sure that << works on has_many associations on unsaved records. Closes #9989 [hasmanyjosh] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8049 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations/association_collection.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 5e2e2e0189..79cd227c0c 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -17,6 +17,7 @@ module ActiveRecord # Since << flattens its argument list and inserts each record, +push+ and +concat+ behave identically. def <<(*records) result = true + load_target if @owner.new_record? @owner.transaction do flatten_deeper(records).each do |record| -- cgit v1.2.3