ryanb / nested_form

Rails plugin to conveniently handle multiple models in a single form.
MIT License
1.79k stars 505 forks source link

in update action any nested field remove then give error. #280

Open gaikwad19 opened 10 years ago

gaikwad19 commented 10 years ago

if in transaction there is product_transaction nested form. in one transaction many no. of products. save transaction then many product_transaction save in linking table with associate transaction. then if we open transaction#edit product_transaction also open. if we remove any product_transaction from transaction edit form and update then after update action it gives error.

rmatesic commented 10 years ago

I am also having this issue. When I click to add new object, it creates it fine and displays it within my form. Say if I click remove object. It disappears and while inspecting the html page it shows that its hidden.

Once I try and click submit, it comes back to that same page showing that the object didn't pass validations, while the params it was sending to the server showed "_destroy"=>"1".

Was wondering how to get around this problem.

naixx commented 10 years ago

Same issue here

levin-ilya commented 10 years ago

I believe this is due to do how Rails 4 access param field. In your Controller you can do this as a quick work around.

def product_line_params
      #TODO: Fix this as it is unsecure.
      params.require(:product_line).permit!
    end

Read this, it is part of Rails 4 core now: https://github.com/rails/strong_parameters