diff options
author | Roman Shterenzon <romanbsd@yahoo.com> | 2008-12-27 01:10:29 +0000 |
---|---|---|
committer | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-27 01:10:29 +0000 |
commit | 21efba464afa2ae6e5dfd938ac8a3ce446faf7e7 (patch) | |
tree | 0d4958fdb36d32a94c3c7295bf4cb129ebcc7507 /activerecord/lib | |
parent | f9cab0e503a4721c9d0369f89bb85c6e658f778c (diff) | |
download | rails-21efba464afa2ae6e5dfd938ac8a3ce446faf7e7.tar.gz rails-21efba464afa2ae6e5dfd938ac8a3ce446faf7e7.tar.bz2 rails-21efba464afa2ae6e5dfd938ac8a3ce446faf7e7.zip |
Fix HasManyAssociation#create ignoring the :primary_key option [#1633 state:resolved]
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 59f1d3b867..676c4ace61 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -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 |