On Feb 6, 2012, at 1:37 PM, Christopher Jones wrote:

> <% Game.all().order('created_at desc').limit(5) %>
> 
> or does it go in the model?

It'll work in either place. (Of course regardless you need the .each() do 
|game| part in the template...)

But I'd put it in the controller as @recent_games =... Generally stuffing 
database access into the .html.erb makes things more complicated than they 
should be. And I would not consider "get the last 5 created..." of anything to 
be part of the model--unlike say routines to parse or format for standard 
display.

-- 
Scott Ribe
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice




-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to