Skip to content

Instantly share code, notes, and snippets.

@jmercedes
Last active December 11, 2015 09:58
Show Gist options
  • Save jmercedes/4582960 to your computer and use it in GitHub Desktop.
Save jmercedes/4582960 to your computer and use it in GitHub Desktop.
Generate Vertically-ordered HTML Table
<% @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