Fix HasManyAssociation#create ignoring the :primary_key option [#1633 state:resolved]

Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
This commit is contained in:
Roman Shterenzon
2008-12-27 01:10:29 +00:00
committed by Frederick Cheung
parent f9cab0e503
commit 21efba464a
2 changed files with 10 additions and 1 deletions

View File

@@ -180,7 +180,10 @@ module ActiveRecord
record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record?
record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s
else
record[@reflection.primary_key_name] = @owner.id unless @owner.new_record?
unless @owner.new_record?
primary_key = @reflection.options[:primary_key] || :id
record[@reflection.primary_key_name] = @owner.send(primary_key)
end
end
end