mercredi 1 février 2017

Use checkbox to save id from nested table

I need a clear way of saving nested measurements along with some other attributes(responsible) to a enquirymeasures table. I tried different things already myself, as you can see below. However, they don't save the values into the enquirymeasures table.

  <% @measurement.each do |m| %>
        <%= f.fields_for :enquirymeasures do |em| %>
            <%#em.number_field :measurement_id %>
            <%#em.check_box :needed, :measurement_id=>m.id %>
            <%# m.measurement %>

                <%= em.check_box :measurement_id, :value => m.id %>
            <li>
              <%= check_box_tag 'measurement_id[]', m.id -%>

              <%= h m.measurement -%>
            </li>
        <% end %>
        <%end%>

Are there any options to save a id from a related table using checkboxes?

Preferably, i want to loop trough measurements table to show the name of the measurement, followed by the checkbox.




Aucun commentaire:

Enregistrer un commentaire