0

I am trying to make a nested model form in which I can add/delete association objects on the fly.

In Rails 3.0.x that would work properly if I created a hidden input with the "_destroy" name that when set to 1 it would have deleted the association record.

Now whenever I submit the form with the hidden input _destroy set to 1 (or true) it doesn't do anything.

Any ideas?

Thanks

1 Answer 1

1

Did you write:

:allow_destroy => true

?

# model.rb
accepts_nested_attributes_for :model, :allow_destroy => true
# view
<%= f.fields_for :model do |fields| %>
...
Delete: <%= fields.check_box :_destroy %>
<% end %>
Sign up to request clarification or add additional context in comments.

1 Comment

Odd enough ... this isn't required in Rails 3.0.x .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.