<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -180,7 +180,10 @@ module ActiveRecord
             record[&quot;#{@reflection.options[:as]}_id&quot;]   = @owner.id unless @owner.new_record?
             record[&quot;#{@reflection.options[:as]}_type&quot;] = @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
 </diff>
      <filename>activerecord/lib/active_record/associations/association_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1115,5 +1115,11 @@ class HasManyAssociationsTest &lt; ActiveRecord::TestCase
     assert !client_association.respond_to?(:private_method)
     assert client_association.respond_to?(:private_method, true)
   end
+
+  def test_creating_using_primary_key
+    firm = Firm.find(:first)
+    client = firm.clients_using_primary_key.create!(:name =&gt; 'test')
+    assert_equal firm.name, client.firm_name
+  end
 end
 </diff>
      <filename>activerecord/test/cases/associations/has_many_associations_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f9cab0e503a4721c9d0369f89bb85c6e658f778c</id>
    </parent>
  </parents>
  <author>
    <name>Roman Shterenzon</name>
    <email>romanbsd@yahoo.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/21efba464afa2ae6e5dfd938ac8a3ce446faf7e7</url>
  <id>21efba464afa2ae6e5dfd938ac8a3ce446faf7e7</id>
  <committed-date>2008-12-26T17:10:29-08:00</committed-date>
  <authored-date>2008-12-26T17:10:29-08:00</authored-date>
  <message>Fix HasManyAssociation#create ignoring the :primary_key option [#1633 state:resolved]

Signed-off-by: Frederick Cheung &lt;frederick.cheung@gmail.com&gt;</message>
  <tree>0d4958fdb36d32a94c3c7295bf4cb129ebcc7507</tree>
  <committer>
    <name>Frederick Cheung</name>
    <email>frederick.cheung@gmail.com</email>
  </committer>
</commit>
