Using Has_one Associations With The Cocoon Gem In Rails

Posted by Weston Ganger

Turns out that using the cocoon gem with a has_one association can be a little weird.

My first point is that you may be better off trying not to use cocoon for has_one associations but if its deeply nested you may have no choice.

We have to add ‘force_non_association_create’ to the ‘link_to_add_association’ to make it work. If you do not add this it will create a new association each time you load the form.

= link_to_add_association('add something', @form_obj, :comments, force_non_association_create: true)

Related External Links:

Article Topic:Software Development - Rails

Date:May 07, 2015

Recommended Posts



Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected