<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -180,10 +180,14 @@ module ActiveRecord
       #   and the Proc should return either +true+ or +false+. When no Proc
       #   is specified a record will be built for all attribute hashes that
       #   do not have a &lt;tt&gt;_delete&lt;/tt&gt; that evaluates to true.
+      #   Passing &lt;tt&gt;:all_blank&lt;/tt&gt; instead of a Proc will create a proc
+      #   that will reject a record where all the attributes are blank.
       #
       # Examples:
       #   # creates avatar_attributes=
       #   accepts_nested_attributes_for :avatar, :reject_if =&gt; proc { |attributes| attributes['name'].blank? }
+      #   # creates avatar_attributes=
+      #   accepts_nested_attributes_for :avatar, :reject_if =&gt; :all_blank
       #   # creates avatar_attributes= and posts_attributes=
       #   accepts_nested_attributes_for :avatar, :posts, :allow_destroy =&gt; true
       def accepts_nested_attributes_for(*attr_names)
@@ -201,7 +205,12 @@ module ActiveRecord
             end
 
             reflection.options[:autosave] = true
-            self.reject_new_nested_attributes_procs[association_name.to_sym] = options[:reject_if]
+
+            self.reject_new_nested_attributes_procs[association_name.to_sym] = if options[:reject_if] == :all_blank
+              proc { |attributes| attributes.all? {|k,v| v.blank?} }
+            else
+              options[:reject_if]
+            end
 
             # def pirate_attributes=(attributes)
             #   assign_nested_attributes_for_one_to_one_association(:pirate, attributes, false)</diff>
      <filename>activerecord/lib/active_record/nested_attributes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,11 +31,27 @@ class TestNestedAttributesInGeneral &lt; ActiveRecord::TestCase
   end
 
   def test_should_add_a_proc_to_reject_new_nested_attributes_procs
-    [:parrots, :birds].each do |name|
+    [:parrots, :birds, :birds_with_reject_all_blank].each do |name|
       assert_instance_of Proc, Pirate.reject_new_nested_attributes_procs[name]
     end
   end
 
+  def test_should_not_build_a_new_record_if_reject_all_blank_returns_false
+    pirate = Pirate.create!(:catchphrase =&gt; &quot;Don' botharrr talkin' like one, savvy?&quot;)
+    pirate.birds_with_reject_all_blank_attributes = [{:name =&gt; '', :color =&gt; ''}]
+    pirate.save!
+
+    assert pirate.birds_with_reject_all_blank.empty?
+  end
+
+  def test_should_build_a_new_record_if_reject_all_blank_does_not_return_false
+    pirate = Pirate.create!(:catchphrase =&gt; &quot;Don' botharrr talkin' like one, savvy?&quot;)
+    pirate.birds_with_reject_all_blank_attributes = [{:name =&gt; 'Tweetie', :color =&gt; ''}]
+    pirate.save!
+
+    assert_equal 1, pirate.birds_with_reject_all_blank.count
+  end
+
   def test_should_raise_an_ArgumentError_for_non_existing_associations
     assert_raise_with_message ArgumentError, &quot;No association found for name `honesty'. Has it been defined yet?&quot; do
       Pirate.accepts_nested_attributes_for :honesty</diff>
      <filename>activerecord/test/cases/nested_attributes_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,11 +28,13 @@ class Pirate &lt; ActiveRecord::Base
     :after_add      =&gt; proc {|p,b| p.ship_log &lt;&lt; &quot;after_adding_proc_bird_#{b.id || '&lt;new&gt;'}&quot;},
     :before_remove  =&gt; proc {|p,b| p.ship_log &lt;&lt; &quot;before_removing_proc_bird_#{b.id}&quot;},
     :after_remove   =&gt; proc {|p,b| p.ship_log &lt;&lt; &quot;after_removing_proc_bird_#{b.id}&quot;}
+  has_many :birds_with_reject_all_blank, :class_name =&gt; &quot;Bird&quot;
 
   accepts_nested_attributes_for :parrots, :birds, :allow_destroy =&gt; true, :reject_if =&gt; proc { |attributes| attributes.empty? }
   accepts_nested_attributes_for :ship, :allow_destroy =&gt; true, :reject_if =&gt; proc { |attributes| attributes.empty? }
   accepts_nested_attributes_for :parrots_with_method_callbacks, :parrots_with_proc_callbacks,
     :birds_with_method_callbacks, :birds_with_proc_callbacks, :allow_destroy =&gt; true
+  accepts_nested_attributes_for :birds_with_reject_all_blank, :reject_if =&gt; :all_blank
 
   validates_presence_of :catchphrase
 </diff>
      <filename>activerecord/test/models/pirate.rb</filename>
    </modified>
    <modified>
      <diff>@@ -57,6 +57,7 @@ ActiveRecord::Schema.define do
 
   create_table :birds, :force =&gt; true do |t|
     t.string :name
+    t.string :color
     t.integer :pirate_id
   end
 </diff>
      <filename>activerecord/test/schema/schema.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>026b78f9076216990bddb1aa5d83d23a647c02a5</id>
    </parent>
  </parents>
  <author>
    <name>Mike Breen</name>
    <login>hardbap</login>
    <email>hardbap@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/9010ed27559ed5ab89ea71b4b16f4c8e56d03dbb</url>
  <id>9010ed27559ed5ab89ea71b4b16f4c8e56d03dbb</id>
  <committed-date>2009-05-09T20:02:00-07:00</committed-date>
  <authored-date>2009-05-09T20:02:00-07:00</authored-date>
  <message>Allow you to pass :all_blank to :reject_if option to automatically create a Proc that will reject any record with blank attributes.</message>
  <tree>cc6198a10a89e8a7017f2f38368e94bdd8348ad6</tree>
  <committer>
    <name>Michael Koziarski</name>
    <login>NZKoz</login>
    <email>michael@koziarski.com</email>
  </committer>
</commit>
