Last active
December 11, 2015 09:58
-
-
Save jmercedes/4582960 to your computer and use it in GitHub Desktop.
Generate Vertically-ordered HTML Table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @rows_per_column = 18 %> | |
<% @columns = 7 %> | |
<table class="table"> | |
<tbody> | |
<tr> | |
<th>Sunday</th> | |
<th>Monday</th> | |
<th>Tuesday</th> | |
<th>Wednesday</th> | |
<th>Thursday</th> | |
<th>Friday</th> | |
<th>Saturday</th> | |
</tr> | |
<% 0.upto(@rows_per_column).each do |row| %> | |
<tr> | |
<%= f.fields_for :schedules do |builder| %> | |
<% 0.upto(@columns - 1).each do |column| %> | |
<% index = row + (column * @rows_per_column) %> | |
<td><%= index %> | |
<div class="field"> | |
<%= builder.label :day %> | |
</div> | |
</td> | |
<% end %> | |
<% end %> | |
</tr> | |
<% end %> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment