From a32a9863640dbd7a74b251e5467f90d134396110 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 12 Feb 2006 18:03:43 +0000 Subject: save polymorphic joins from the has_many|one association (closes #3812) [Rick Olson] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3586 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations/has_many_association.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations/has_many_association.rb') diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 6800f363dc..b861fde55d 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -13,7 +13,7 @@ module ActiveRecord else load_target record = @reflection.klass.new(attributes) - record[@reflection.primary_key_name] = @owner.id unless @owner.new_record? + set_belongs_to_association_for(record) @target << record record end @@ -140,7 +140,7 @@ module ActiveRecord end def insert_record(record) - record[@reflection.primary_key_name] = @owner.id + set_belongs_to_association_for(record) record.save end -- cgit v1.2.3