This is what I am trying to do:
<% Topic.all.each do |topic| %>
<%= f.check_box "topic_ids[]", topic.id, false %>
<% end %>
That is inside a form_for.
This is the error I get:
undefined method `merge' for 1:Fixnum
Around the main check_box line.
My Topic model actually looks like this, and I would like for the checkboxes to display the name of the topics on each checkbox:
# Table name: topics
#
# id :integer not null, primary key
# name :string(255)
What am I missing?
You should use
check_box_taginstead off.check_box.The difference is
f.check_boxis for model-bounded forms and the value supplied to the check box is implicit from the given model and doesn’t need to be provided.