ruby on rails 3 - Loop and generate table cells -


  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 What to do Hospice | & 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; Not every day & lt; / Td> & Lt; / TR & gt; & Lt;% end -% & gt; & Lt;% @ dates.each do | Date | & Gt%; & Lt; TR & gt; & Lt; Td> & Lt;% = date.inspect% & gt; & Lt; / Td> & Lt;% end% & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;   

Which of the following output is:

I am trying to make empty lines blank lines, I can not know where I'm going wrong I am What is the best possible solution?

Renewed version

  & lt; Table class = "rota" & gt; & Lt; Thead & gt; & Lt; Th & gt; Date & lt; / Th & gt; & Lt;% @ Hospitals What to do Hospice | & 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; Not every day & lt; / Td> & Lt; / TR & gt; & Lt;% end -% & gt; & Lt;% @ dates.each do | Date | & Gt%; & Lt; TR & gt; & Lt; Td> & Lt;% = date.inspect% & gt; & Lt; / Td> & Lt;% (1 .. @ Hospitals count.). What to do%> & Lt; TD & gt; & Lt; / TD & gt; & Lt;% end% & gt; & Lt; / TR & gt; & Lt;% end% & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;    

You are ending your loop very soon and you have a TD for each If needed, then change:

   & Lt;% = date.inspect% & gt; & Lt; / Td> & Lt;% end% & gt; & Lt; / TR & gt;   

To:

  & lt;% @ dates.each do | Date | & Gt%; & Lt; TR & gt; & Lt; Td> & Lt;% = date.inspect% & gt; & Lt; / Td> & Lt;% (1 .. @ Hospitals count.). What to do%> & Lt; TD & gt; & Lt; / TD & gt; & Lt;% end% & gt; & Lt; / TR & gt; & Lt;% end% & gt;    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -