Okay this one should be easy, which means I'm on the verge of pulling out hairs!
I'll try to keep the explanation simple.
I have a form, to create a new "case." These cases have individual "parts."
I'm trying to have a list of checkboxes so you can check off the parts you'll need, click add, and then display the titles of the parts that are included.
What's happening instead is, I select the part via the checkbox, click add, then the WHOLE LIST of items, including checkboxes, gets added to the page. I just want the selected part titles to show up.
Here are my forms:
_form.html.erb
<%= simple_form_for @case, html: { multipart: true } do |f| %>
<%= f.input :image, as: :file %>
<%= f.input :title, label: "Case" %>
<%= f.input :description, label: "Parts" %>
<%= f.simple_fields_for :parts do |part| %>
<%= render 'part_fields', f: part %>
<%= link_to_add_association 'Add Part', f, :parts, class: "btn btn-default add-button" %>
<% end %>
<%= f.button :submit %>
<% end %>
_parts_fields.html.erb
<%= f.label "Parts list" %><br />
<%= f.collection_check_boxes :title, Part.all, :id, :title do |b| %>
<div class="collection-check-box">
<%= b.check_box %>
<%= b.label %>
</div>
<% end %>
I don't know what other code I need to post, so let me know if there's anything else you need.
Also, I'd like to add quantities but am not really sure where to start with that. If someone could help with that, or just point me in the right direction, that would be greatly appreciated!
Thanks
has_and_belongs_to_manyassociation instead ofhas_many, now his solution works. :)