Topic: Nested Loops and Pagnation
With this snippet of code I can organize games into categories on a page. The problem is I can't find a way to limit the amount of games that are displayed using paginate or anything else. It also probably shouldn't all be in the rhtml file but , that is the way it is because I can't figure out how to do it any other way. Help is greatly appreciated.
<table>
<% @categories = Category.find(:all) %>
<% for category in @categories%>
<tr>
<% @games = Game.find_all_by_category_id(category.send('id')) %>
<td><h2><%= category.send('title') %></h2></td>
<% for game in @games %>
<td><%= link_to game.send('title'), :action => 'show', :id => game.send('id') %></td>
<% end %>
</tr>
<% end %>
</table>
Last edited by kamhp (2006-12-04 16:27:25)