ryanb / nested_form

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

`data-association` not added for double nested form #288

Open ryanjm opened 10 years ago

ryanjm commented 10 years ago

I am working on a project that is using a double nested form. Add/remove works fine, as expected. But the remove link doesn't get the data-association that it should.

According to the specs this should work. I'm not sure if it is because it is a has_one association instead of a has_many.

In the code I'm not really sure where object_name is coming from so I'm not sure where to look to solve the issue.

Are we missing something or is this a bug?

Laykou commented 10 years ago

I am reporting the same issue. To fix this immediately this should helps:

<%= f.link_to_remove "Remove the location", class: 'btn btn-danger', data: {association: 'location'} %>

Just add

data: {association: 'location'}

where "location" is name of your nested form.

Startouf commented 9 years ago

Thanks for the fix it works like a charm !