mirror of
https://github.com/github/rails.git
synced 2026-02-16 17:15:29 -05:00
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:
committed by
Frederick Cheung
parent
f9cab0e503
commit
21efba464a
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user