views:

18

answers:

0

I'm having a problem with a rails form that contains a dynamic number of new models in one form. The models are all from the same class and are nested under one single model. How I have it set up right now works great for HTML form submissions. But, when I change the form from form_for to form_remote_for, the parameters get completely messed up. The parameters are only messed up if I have more than one model in the form -- if it is just one then it works out great.

Here are the parameters for the HTML submission: Parameters: {"commit"=>"Submit", "new_bom_parts"=>[{"x"=>"", "quantity"=>"3", "fab_level"=>"", "y"=>"", "layer"=>"", "ref_des"=>"", "dni"=>"0", "part_id"=>"A2", "rotation"=>""}, {"x"=>"", "quantity"=>"3", "fab_level"=>"", "y"=>"", "layer"=>"", "ref_des"=>"", "dni"=>"0", "part_id"=>"A3", "rotation"=>""}], "authenticity_token"=>"R30KlDULZ5oUWtnQ3mQI0PRULLcsJYHsvcgZ2fRaIdw=", "part_id"=>"C00055"}

Here are the parameters for the AJAX equivalent: Parameters: {"commit"=>"Submit", "new_bom_parts"=>[{"part_id"=>"A2"}, {"ref_des"=>"", "part_id"=>"A3"}, {"quantity"=>"3", "ref_des"=>""}, {"quantity"=>"3", "dni"=>"0"}, {"x"=>"", "dni"=>"0"}, {"x"=>"", "y"=>""}, {"y"=>"", "rotation"=>""}, {"layer"=>"", "rotation"=>""}, {"fab_level"=>"", "layer"=>""}, {"fab_level"=>""}], "authenticity_token"=>"R30KlDULZ5oUWtnQ3mQI0PRULLcsJYHsvcgZ2fRaIdw=", "part_id"=>"C00055"}

I basically used the rails recipe from this pdf: http://media.pragprog.com/titles/fr_arr/multiple_models_one_form.pdf

Are there any special parameters I need in a remote_form_for that I don't need in a form_for for this? Let me know if you need to see the code -- it's a lot so I'll need to put it on pastie or something.