Using :limit and :order in the associated model
- by r2b2
Hello,
Is there any way i can limit the results of an associated model?
This what i was trying to do :
<ul>
<% account.logins.slice(0,5).sort_by(&:login_date).reverse.each do |login| -%>
<li><%=h login.login_date.strftime("%d.%m.%Y")%></li>
<% end -%>
</ul>
I'm trying to get the last five logins of the account. I cant seem to do it with account.logins(:limit=5)
Thanks !