josevalim/inherited_resources — Issue #203: Nested form problem
Author: lecky-ambit
Created: 2012-02-01 07:48:17+00:00
State: open

There's a problem that on controller update method is not updating the data record. But the flash message still said update successfully. And there's no error. Turn out that it's not calling the update.

Log message:

Started PUT ******
Parameters: {****** "type"=>"Person", "addresses_attributes"=>{"0"=>{********}}}, "commit"=>"Update", "id"=>"4"}
Load (0.2ms) *****

Which is expected to be this:

Started PUT *****
Parameters: {********** "type"=>"Person"}, "person"=>{"addresses_attributes"=>{"0"=>{"************}}}, "commit"=>"Update", "id"=>"4"}
Load (0.2ms) ********
(0.5ms) UPDATE "parties" SET "name" = 'Abbotttt' ********

As you can see the difference is the form post parameters. The fail form is passing the form object which is the way commonly use but failed:

%li
= f.label :name
= f.text_field :name

The success form is manually passing the form object:

%li
= label_tag :party_name, 'Name'
= text_field :party, :name

Not sure if this issue is related to single table inheritance, and I am using Person < Party.