Using :limit and :order in the associated model
        Posted  
        
            by r2b2
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by r2b2
        
        
        
        Published on 2010-04-19T08:39:24Z
        Indexed on 
            2010/04/19
            8:43 UTC
        
        
        Read the original article
        Hit count: 287
        
ruby-on-rails
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 !
© Stack Overflow or respective owner