<% contester.lineup.each do |teamer| %>
<% if matcher = @match.matchers.first(conditions: { user_id: teamer.user_id, contester_id: contester.id }) %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][id]", matcher.id %> <% end %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][user_id]", teamer.user_id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][contester_id]", contester.id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][match_id]", @match.id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][merc]", false %> <%= check_box_tag "match[matchers_attributes][#{@n}][_destroy]", "keep", !matcher.nil?, { id: "player_#{@n}" } %> <%= label_tag "player_#{@n}", '', class: 'checkbox' %> <%= teamer.user %>
<% @n = @n + 1 %> <% end %>
<% @match.matchers.mercs.of_contester(contester).each do |matcher| %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][id]", matcher.id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][user_id]", matcher.user_id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][contester_id]", contester.id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][match_id]", @match.id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][merc]", true %> <%= check_box_tag "match[matchers_attributes][#{@n}][_destroy]", "keep", true, { id: "player_#{@n}" } %> <%= label_tag "player_#{@n}", '', class: 'checkbox' %> <%= matcher.user %>
<% @n = @n + 1 %> <% end %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][contester_id]", contester.id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][match_id]", @match.id %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][merc]", true %> <%= hidden_field_tag "match[matchers_attributes][#{@n}][_destroy]", "keep" %> <%= text_field_tag "match[matchers_attributes][#{@n}][user_id]", '', placeholder: 'Mercenary' %> <% @n = @n + 1 %>