我有一个生成篮球队表格的脚手架。我想在表格中实现一个按钮,增加一个团队的胜利次数和另一个失败次数。默认情况下,控制器中的两者都设置为 0。我应该在控制器或视图中实现方法(add_wins 和 add_losses)吗?如果是这样,它会是什么样子?谢谢你。这是视图中表格主体的代码:
<tbody>
<% @teams.each do |team| %>
<tr>
<td><%= team.Name %></td>
<td><%= team.Color %></td>
<td><%= team.Players %></td>
<td><%= team.Wins %></td>
<td style="font-size: 20px"><%= button_to '+', method: :add_wins %></td> <!-- The method add_wins doesn't exist. -->
<td><%= team.Losses %></td>
<td style="font-size: 20px"><%= button_to '+',method: :add_losses %></td> <!-- The method add_losses doesn't exist. -->
<td><%= link_to 'Show', team %></td>
<td><%= link_to 'Edit', edit_team_path(team) %></td>
<td><%= link_to 'Delete', team, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>