==The Problem: The parameter structure in the current implementation of nested attributes does support both modification and replacement of existing has_one records.
==The Solution: Move ids inside the hash. That is, instead of:
@pirate.birds_attributes = { ‘12’ => { :name => ‘Polly’ }, ‘new_1’ => { :name => ‘Wally’ } }
we have:
@pirate.birds_attributes = { ‘0’ => { :id => ‘12’, :name => ‘Polly’ }, ‘1’ => { :name => ‘Wally’ } }
which naturally extends to has_one associations to allow both modification:
@pirate.ship_attributes = { :id => ‘5’, :name => ‘Bessy’ }
and replacement:
@pirate.ship_attributes = { :name => ‘Henry’ }
==The Patch: http://rails.lighthouseapp.com/projects/8994/tickets/1892-nested-attributes-should-not-have-meaningful-hash-keys
-Lance