Hi There,
First post in a while, so here goes...
I've been doing a lot of Ruby on Rails development lately, but can't figure out one thing. I have two different "scaffolds", one called 'games' and another called 'videos'.
I want to have the latest 5 from each displayed on the homepage, but can't figure out how to tell Rails to do so.
I'm assuming there's a statement I can put either in or before the 'each' block?
Edit: UPDATE: Here's my code:
Code:<ul class="gallery latest"> <% @games.each do |game| %> <li class="game"> <%= link_to image_tag("games/" + game.slug + ".jpg", :border=>0), game %> <div class="name"><%= game.title %></div> </li> <% end %> </ul> <ul class="gallery latest"> <% @videos.each do |video| %> <li class="video"> <%= link_to image_tag("videos/" + video.slug + ".jpg", :border=>0), video %> <div class="name"><%= video.title %></div> </li> <% end %> </ul>
Thanks,
Alex



Reply With Quote
rder => "id desc", :limit => 5)
Bookmarks