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>
输出以下内容:
我正在尝试生成包含空单元格的空白行。我似乎无法确定我哪里出错了。什么是最好的解决方案
更新后的版本
<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>