title: Loop and generate table cells
body: <pre><code>I have a table that looks like the following: 
  
  &lt;table class = "rota"&gt;
      &lt;thead&gt;
          &lt;th&gt;Date&lt;/th&gt; 
          &lt;% @hospitals.each do |hosp| %&gt;
          &lt;th&gt;&lt;%= hosp.name%&gt;&lt;/th&gt;
          &lt;% end %&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;%- if @rota_days.blank? %&gt;
          &lt;tr&gt;
              &lt;td colspan="&lt;%= @hospitals.count %&gt;"&gt;No rota day&lt;/td&gt;
          &lt;/tr&gt;
          &lt;% end -%&gt;
          &lt;% @dates.each do |date| %&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;%= date.inspect %&gt;&lt;/td&gt;
  
              &lt;% end %&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Which outputs the following: </p>
  
  <p><img src="https://i.imgur.com/KseiT.png" alt="the output"></p>
  
  <p>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 </p>
  
  <p>Updated version </p>
  
  <pre><code>&lt;table class = "rota"&gt;
      &lt;thead&gt;
          &lt;th&gt;Date&lt;/th&gt; 
          &lt;% @hospitals.each do |hosp| %&gt;
          &lt;th&gt;&lt;%= hosp.name%&gt;&lt;/th&gt;
          &lt;% end %&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;%- if @rota_days.blank? %&gt;
          &lt;tr&gt;
              &lt;td colspan="&lt;%= @hospitals.count %&gt;"&gt;No rota day&lt;/td&gt;
          &lt;/tr&gt;
          &lt;% end -%&gt;
          &lt;% @dates.each do |date| %&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;%= date.inspect %&gt;&lt;/td&gt;
              &lt;% (1..@hospitals.count).each do %&gt; 
                  &lt;td&gt;&lt;/td&gt; 
              &lt;% end %&gt; 
             &lt;/tr&gt; 
              &lt;% end %&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>