Reputation: 634
I have a form_tag in which I display a table, one column of that table it has a check_box_tag
<%@competitors.each do |competitor|%>
<td><%= check_box_tag "competitor_ids[]", competitor.id%></td>
<%end%>
Is it possible to tick just the first competitor
and submit the form and how?
Upvotes: 0
Views: 55
Reputation: 38645
You can use each_with_index
as follows to check
the checkbox at zero
index:
<% @competitors.each_with_index do |competitor, index| %>
<td><%= check_box_tag "competitor_ids[]", competitor.id, index.zero? %></td>
<% end %>
Upvotes: 1