views:

51

answers:

0

i am having trouble updating data in a multi-level nested form. i use partials to include all the fields for both the create & update views, and i do NOT have a problem with creating. only with updating.

essentially the structure (simplified) is:

user has_one profile
profile has_many addresses

form_for @user do |u|
  u.fields_for :profile do |p|
    p.fields_for :addresses do |a|

like i said, creating the user, profile, and addresses works fine. only until i attempt to update do i find problems. i don't receive an error, it actually shows it was successfully updated. and it actually does properly update the user & profile fields, just not the address fields.

here are the params for the update from the stack trace. (again, summarized & formatted)

Parameters: {"controller"=>"profiles", "action"=>"update", "_method"=>"put", "id"=>"1", 
  "user"=>{"login" => "username",
    "profile_attributes"=>{"first_name"=>"Admin",
      "addresses_attributes"=>{
        "0"=>{"address"=>"123 Address Ave.", "city"=>"Cityville", "state"=>"CA"}
      }
    }
  }
}

all of the documentation i can find only shows 1 nested form, so i am not sure if i am using update_attributes properly for more than 1 level deep.

any thoughts?