Edit With Nested Forms - Values Not Preserved Across Submit

When a nested form submitted to the create action contains missing data, the form is redisplayed and the nested values the user entered remain. When submitting the same nested form to the update action, the newly entered values remain for the parent record, but the child records revert back to their pre edit values.

Here's the form (from Rails Guides):

<% form_for @customer do |customer_form| %>   <div>     <%= customer_form.label :name, 'Customer Name:' %>     <%= customer_form.text_field :name %>   </div>

  <% customer_form.fields_for :orders do |order_form| %>     <p>       <div>         <%= order_form.label :number, 'Order Number:' %>         <%= order_form.text_field :number %>       </div>

      <% unless order_form.object.new_record? %>         <div>           <%= order_form.label :_delete, 'Remove:' %>           <%= order_form.check_box :_delete %>         </div>       <% end %>     </p>   <% end %>

  <%= customer_form.submit %> <% end %>

It looks like this is a problem with accepts_nested_attributes_for. It loads and updates the records in the nested form, but when the form is redisplayed @customer.orders is loaded from the DB, squashing the changes by the nested attributes module.

Is it possible to retain nested data across form redisplays to the update action?

Anyone?

The answer appears to be no, given the Rails Guides example and the Complex Forms Examples: github.com/alloy/complex-form-examples/tarball/ master. This is a big downside to using nested attributes with complex forms.