title: accepts_nested_attributes_for child association validation failing
body: <p>I'm using accepts_nested_attributes_for in one of my Rails models, and I want to save the children after creating the parent.</p>
  
  <p>The form works perfectly, but the validation is failing. For simplicity's sake imagine the following:</p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
    has_many :tasks
    accepts_nested_attributes_for :tasks
  end
  
  class Task &lt; ActiveRecord::Base
    belongs_to :project
  
    validates_presence_of :project_id
    validates_associated :project
  end
  </code></pre>
  
  <p>And I am running:</p>
  
  <pre><code>Project.create!(
    :name =&gt; 'Something',
    :task_attributes =&gt; [ { :name =&gt; '123' }, { :name =&gt; '456' } ]
  )
  </code></pre>
  
  <p>Upon saving the project model, the validation is failing on the tasks because they don't have a project_id (since the project hasn't been saved).</p>
  
  <p>It seems like Rails is following the pattern below:</p>
  
  <ul>
  <li>Validate Project</li>
  <li>Validate Tasks</li>
  <li>Save Project</li>
  <li>Save Tasks</li>
  </ul>
  
  <p>The pattern should be:</p>
  
  <ul>
  <li>Validate Project</li>
  <li>On Pass: Save Project and continue...</li>
  <li>Validate Tasks
  
  <ul>
  <li>On Pass: Save Tasks</li>
  <li>On Fail: Delete Project (rollback maybe?)</li>
  </ul></li>
  </ul>
  
  <p>So my question boils down to: How can I get Rails to run the project_id= (or project=) method and validation on the children (tasks) AFTER the parent (project) has been saved, but NOT save the parent (project) model if any child (task) is invalid?</p>
  
  <p>Any ideas?</p>