Okay, so you're making a form for a new Game. You now have to feed that new Game, along with some Participants to your view.
def new
@game = Game.new
@participants = User.all # or the users you want
end
Now use those in your view. You were on the right track. Depending on how your create
action works:
<% @participants.each do |p| %>
<%= check_box_tag "participants[#{p.id}]" %> <%= p.name %>
<% end %>
I think what you were missing was the documentation for check_box_tag
. The input
attribute name
is the argument.
You also seem to have a lot of logic in your controllers. Remember to keep the logic in the models, and only use the controllers to give the right objects to your views, and taking them for saving, for example. As the saying goes, "fat model, skinny controller".