Search code examples
ruby-on-railscocoon-gem

Rails cocoon dynamic creation of link_to_add_association


I have a form which allows the adding of possibly hundreds of different association types to a form. I'm using the cocoon gem's link_to_add_association but rendering 100's of links is very slow as they're populated with all the html required to add them. Is there any way to dynamically create the links from an ajax request? The problem is link_to_add_association requires the form builder object which is unavailable after the initial page request.

As a side note the links are grouped so if I'm hoping to render the links for that particular group when it's clicked.


Solution

  • I ended up rendering a new form for each request which seemed to work just fine.