This is my code:
<table class="video_table">
<% count = 0 %>
<tr>
<% @f_videos.each do |f_video| %>
<td><%= f_video.name %></td>
<td><%= f_video.date_added %></td>
<td><%= f_video.views %></td>
<% count +=1 %>
<% if count == 4 %>
</tr>
<% end %>
<% end %>
</table>
at each 4 videos placed I want the table to switch row. So I implemented a counter.
But it is not working. Any ideas?
Your count will only be set to 4 once.
Instead of
if count == 4useif count % 4 == 0This will repeat the
</tr>for each multiple of 4Alternatively, you could skip using the count variable and use
each_with_indexto get the same resultEven better!
each_slice