I have a table that looks like the following:
<table class = "rota">
<thead>
<th>Date</th>
<% @hospitals.each do |hosp| %>
<th><%= hosp.name%></th>
<% end %>
</thead>
<tbody>
<%- if @rota_days.blank? %>
<tr>
<td colspan="<%= @hospitals.count %>">No rota day</td>
</tr>
<% end -%>
<% @dates.each do |date| %>
<tr>
<td><%= date.inspect %></td>
<% end %>
</tr>
</tbody>
</table>
Which outputs the following:

I am trying to generate blank rows that contain empty cells. I cannot seem to identify where I am going wrong. What is the best possible solution
Updated version
<table class = "rota">
<thead>
<th>Date</th>
<% @hospitals.each do |hosp| %>
<th><%= hosp.name%></th>
<% end %>
</thead>
<tbody>
<%- if @rota_days.blank? %>
<tr>
<td colspan="<%= @hospitals.count %>">No rota day</td>
</tr>
<% end -%>
<% @dates.each do |date| %>
<tr>
<td><%= date.inspect %></td>
<% (1..@hospitals.count).each do %>
<td></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
You’re ending your loop too soon and you’ll need a td for each th so change:
To: