I have a checkbox form where you can select many customers to attend a single event. The form works but there is an array of all customers under it and I can't figure out how to remove it.
events.rb
def addcustomer
@event = Event.find(params[:id])
@customer = Customer.all
end
routes.rb
resources :events do
get 'addcustomer', on: :member, as: 'add'
end
addcustomerform.html.erb
<%= form_for(@event) do |f| %>
<%= hidden_field_tag "event[customer_ids][]", nil%>
<%= @customer.each do |customer| %>
<%= check_box_tag "event[customer_ids][]", customer.id,
@event.customer_ids.include?(customer.id), id:dom_id(customer) %>
<%= label_tag dom_id(customer), customer.id %>
<%= label_tag dom_id(customer), customer.name %> --
<%= label_tag dom_id(customer), customer.email %> --
<%= label_tag dom_id(customer), customer.phone %>
<br>
<% end %>
<br>
<%= f.submit%>
<% end %>
Here is a photo of what the issue looks like:
Here is the repo https://github.com/robbiesoho/fanfactory
I hope someone can help. Thank you