views:

65

answers:

1

I have an interesting conundrum. I have a table of programs that has_many install_validations that have many install_validation_reactions (don't ask!). I set the program model to accepts_nested_attributes_for :install_validations, :allow_destroy => true, and the same between the install_validations and install_validation_reactions. Built a form, that has all three layers in it, and here's the behaviour I am seeing: if I create a new install validation, I can add or remove as many install validation reactions from it as I like, and they will save properly. If I change any of the attributes of an existing install validation, it will save properly. BUT. If I edit one of the existing nested install validation reactions, the changes do not save, and I can't delete them either. The data being submitted looks fine, so I don't think it's the view. Here's an example:

Parameters: {"authenticity_token"=>"1I4eJypbS7FxQkLkkvUqqWGEdLhbR2K/f/qIsvb2sm8=", "package"=>{"name"=>"Adobe Acrobat 7", "platform"=>"PC", "licensed"=>"1", "deployment_stage"=>"1", "source_path"=>"adobe/Acrobat 7/", "executable"=>"install.bat", "install_validations_attributes"=>{"0"=>{"success_value"=>"true", "rule_type"=>"ExecRunning", "rule_parameter"=>"Pork Chops", "install_validation_reactions_attributes"=>{"0"=>{"command"=>"wait", "parameter"=>"30", "id"=>"6", "_destroy"=>"1"}}, "_destroy"=>"false", "id"=>"56"}, "1"=>{"success_value"=>"true", "rule_type"=>"ExecRunning", "rule_parameter"=>"pooka", "install_validation_reactions_attributes"=>{"0"=>{"command"=>"repeat", "parameter"=>"3", "id"=>"7", "_destroy"=>"false"}}, "_destroy"=>"false", "id"=>"57"}}}, "commit"=>"Update", "id"=>"7"}

So, that looks right, right? And like the install validation reaction 0 of install validation 0 is set to delete, right? But it doesn't. No error, nothin'. IT just doesn't delete it. Any ideas? The views, like i said, I think are probably fine, since the data in the params looks fine (I think? If it's wrong, let me know!). So, what data would help you wonderful people give me some insight?

I'm, incidentally, running ruby 1.9.1p376, and rails 3.0.0.beta3.

A: 

Nevermind, I'm an idiot. You need to put in a field so that the id field is submitted for each of the child and grandchild objects. Once you does, the update can determine which object to update.

jasonpgignac