<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -166,12 +166,18 @@ module ActiveRecord
         if attrs.is_a?(Array)
           attrs.collect { |attr| create(attr) }
         else
-          create_record(attrs) { |record| record.save }
+          create_record(attrs) do |record|
+            yield(record) if block_given?
+            record.save
+          end
         end
       end
 
       def create!(attrs = {})
-        create_record(attrs) { |record| record.save! }
+        create_record(attrs) do |record|
+          yield(record) if block_given?
+          record.save!
+        end
       end
 
       # Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and</diff>
      <filename>activerecord/lib/active_record/associations/association_collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -161,12 +161,15 @@ class AssociationProxyTest &lt; ActiveRecord::TestCase
   end
 
   def test_create_via_association_with_block
-    post1 = Post.create(:title =&gt; &quot;setting body with a block&quot;) {|p| p.body = &quot;will work&quot;}
-    assert_equal post1.body, &quot;will work&quot;
-    assert_nothing_raised do
-      post2 = authors(:david).posts.create(:title =&gt; &quot;setting body with a block&quot;) {|p| p.body = &quot;won't work&quot;}
-    end
-    assert_equal post2.body, &quot;won't work&quot;
+    post = authors(:david).posts.create(:title =&gt; &quot;New on Edge&quot;) {|p| p.body = &quot;More cool stuff!&quot;}
+    assert_equal post.title, &quot;New on Edge&quot;
+    assert_equal post.body, &quot;More cool stuff!&quot;
+  end
+
+  def test_create_with_bang_via_association_with_block
+    post = authors(:david).posts.create!(:title =&gt; &quot;New on Edge&quot;) {|p| p.body = &quot;More cool stuff!&quot;}
+    assert_equal post.title, &quot;New on Edge&quot;
+    assert_equal post.body, &quot;More cool stuff!&quot;
   end
 
   def test_failed_reload_returns_nil</diff>
      <filename>activerecord/test/cases/associations_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b88ceb7dc8d31bdbea95ab4242bbdee17178cda9</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Bates</name>
    <login>ryanb</login>
    <email>ryan@railscasts.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/6cba97d2a449faf21aec9fe9d4434067e414226f</url>
  <id>6cba97d2a449faf21aec9fe9d4434067e414226f</id>
  <committed-date>2008-05-23T23:26:13-07:00</committed-date>
  <authored-date>2008-05-23T14:57:11-07:00</authored-date>
  <message>Create through associations can now work with blocks.

Signed-off-by: Michael Koziarski &lt;michael@koziarski.com&gt;

[#248 state:resolved]</message>
  <tree>3c00a108230fe3471882678f362f4c138e6567df</tree>
  <committer>
    <name>Michael Koziarski</name>
    <login>NZKoz</login>
    <email>michael@koziarski.com</email>
  </committer>
</commit>
