Rails partial show latest 5 kases
Posted
by Danny McClelland
on Stack Overflow
See other posts from Stack Overflow
or by Danny McClelland
Published on 2010-05-07T18:25:03Z
Indexed on
2010/05/07
18:28 UTC
Read the original article
Hit count: 349
Hi Everyone,
I have my application setup with a few different partials working well. I have asked here how to get a partial working to show the latest entry in the kase model, but now I need to show the latest 5 entries in the kase model in a partial.
I have duplicated the show most recent one partial and it's working where I need it to but only shows the last entry, what do I need to change to show the last 5?
_recent_kases.html.erb
<% if Kase.most_recentfive %>
<h4>The most recent case reference is <strong><%= Kase.most_recentfive.jobno %></strong></h4>
<% end %>
kase.rb
def self.most_recentfive
first(:order => 'id DESC')
end
Thanks,
Danny
© Stack Overflow or respective owner