I'm getting a bit crazy with this, I have a Event who has_many Attendants but I haven't been able to create dynamically inside the Event form, I have a partial with the form of Attendant, this works:
<%= form.fields_for :attendants do |form_attendant| %>
<%= render 'form_attendant', form_attendant: form_attendant %>
<% end %>
for 1 attendant, if I copy-paste that, it works for 2 and so on..
I want a button to do that for me, I've read and tried a loooot.
Option 1: I have tried in js to append that, with:
$("#attendants").append "<%= form.fie ... %>"
but It just print the text and won't render the partial, I have tried with escape_javascript too with no luck.
I'm now trying with:
<%= link_to "Agregar", new_attendant_path, remote: true %>
I have these in attendants/new.js.erb
$('#attendants').append("<%= escape_javascript ( render partial: 'form_attendants' ) %>");
Which actually works and render the partial but now I don't know how to send the local event form so I can make
<%= form.fields_for :attendants do |form_attendant| %> ... inside the partial,
Any help would be appreciated, I'm almost crying