I'm having an issue trying to loop through two team results grouping by date. So far my method only produces the first letter of each loop and puts the two results in 2 rows.
My table data is as such:
|matchId| matchDate |teamId|goals|
| 101 |2016-05-14 11:40:00| 10 | 3 |
| 101 |2016-05-14 11:40:00| 20 | 2 |
Controller (Would it be possible to group by just week and month?)
@games = Match.all.group_by { |m| m.matchDate }
View
<table class="table table-bordered">
<th colspan='5'>Match</th>
<th>Team Name 1</th>
<th>Team Score 1</th>
<th></th>
<th>Team Name 2</th>
<th>Team Score 2</th>
<% @games.each do |date, games| %>
<tr class="match-date">
<td colspan='5'><%= date %></td>
</tr>
<% games.each do |match| %>
<tr>
<td><%= match.teamId[0] %></td>
<td><%= match.goals[0] %></td>
<td>VS</td>
<td><%= match.teamId[1] %></td>
<td><%= match.goals[1] %></td>
</tr>
<% end %>
<% end %>
</table>