Rails accepts_nested_attributes_for not deleting/removing associations.

Trying to save some others going through this pain. I have a parent and child associations both in the same form.

In parent i added `accepts_nested_attributes_for :child` and thought its going to take care of everything which is wrong. This helps in `create` and `update` but not in `delete`. To delete the child association you need to mention allow_destroy: true

accepts_nested_attributes_for :child, allow_destroy: true

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.