<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1105,6 +1105,10 @@ module ActiveRecord
               association = association_proxy_class.new(self, reflection)
             end
 
+            # if a Hash is passed in, convert it to an ActiveRecord model
+            # using the Hash as the initialization attributes
+            new_value = reflection.klass.new(new_value) if new_value.is_a?(Hash)
+
             if association_proxy_class == HasOneThroughAssociation
               association.create_through_record(new_value)
               self.send(reflection.name, new_value)</diff>
      <filename>activerecord/lib/active_record/associations.rb</filename>
    </modified>
    <modified>
      <diff>@@ -94,6 +94,11 @@ module ActiveRecord
 
         @owner.transaction do
           flatten_deeper(records).each do |record|
+
+            # if a Hash is passed in, convert it to an ActiveRecord model
+            # using the Hash as the initialization attributes
+            record = @reflection.klass.new(record) if record.is_a?(Hash)
+
             raise_on_type_mismatch(record)
             add_record_to_target_with_callbacks(record) do |r|
               result &amp;&amp;= insert_record(record) unless @owner.new_record?</diff>
      <filename>activerecord/lib/active_record/associations/association_collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -189,6 +189,24 @@ class AssociationProxyTest &lt; ActiveRecord::TestCase
     end
   end
 
+  def test_association_proxy_setter_can_take_hash
+    special_comment_attributes = { :body =&gt; 'Setter Takes Hash' }
+
+    post = posts(:welcome)
+    post.very_special_comment = { :body =&gt; 'Setter Takes Hash' }
+
+    assert_equal post.very_special_comment.body, special_comment_attributes[:body]
+  end
+
+  def test_association_collection_can_take_hash
+    post_attributes = { :title =&gt; 'Setter Takes', :body =&gt; 'Hash' }
+
+    david = authors(:david)
+    post = (david.posts &lt;&lt; post_attributes).last
+
+    assert_equal post.title, post_attributes[:title]
+  end
+
   def setup_dangling_association
     josh = Author.create(:name =&gt; &quot;Josh&quot;)
     p = Post.create(:title =&gt; &quot;New on Edge&quot;, :body =&gt; &quot;More cool stuff!&quot;, :author =&gt; josh)</diff>
      <filename>activerecord/test/cases/associations_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d7462ea36550bd59cfbcd7961f5870c49bcf8963</id>
    </parent>
  </parents>
  <author>
    <name>David Dollar</name>
    <email>ddollar@gmail.com</email>
  </author>
  <url>http://github.com/ddollar/rails/commit/cf8e34d59cd81c3874d97668a72bb61949c50da8</url>
  <id>cf8e34d59cd81c3874d97668a72bb61949c50da8</id>
  <committed-date>2008-06-23T11:25:47-07:00</committed-date>
  <authored-date>2008-06-23T11:25:47-07:00</authored-date>
  <message>if a hash is passed into an association proxy setter, hydrate it as an ActiveRecord model instead</message>
  <tree>87f9e27ada499c6d7047496b33d39333626227f3</tree>
  <committer>
    <name>David Dollar</name>
    <email>ddollar@gmail.com</email>
  </committer>
</commit>
