# Paginate @member.items?

**URL:** <https://www.ruby-forum.com/t/paginate-member-items/53708>\
**Category:** Rails\
**Created:** [February 13, 2006, 10:13pm UTC](https://www.ruby-forum.com/t/paginate-member-items/53708 "2006-02-13T22:13:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [February 13, 2006, 10:13pm UTC](https://www.ruby-forum.com/t/paginate-member-items/53708/1 "2006-02-13T22:13:01Z")

</div>

Is there a quick and easy way to paginate something  
like @member.items (Member with has\_many :items)?  
Right now I do in the controller:

@item\_pages, @member\_items = paginate :item,  
:conditions=\>[“member\_id=?”, @member.id],  
:per\_page=\>25,  
:order=\>‘datetime desc’

It’d be more DRY if this was possible:

@item\_pages, @member\_items = paginate @member.items,  
:per\_page=\>25,  
:order=\>‘datetime desc’

And even more so if it could all be done in the  
template:

\<% for item in @member.items(:limit=\>25,  
:offset=\>params[:page]\*25) %\>  
…  
\<% end %\>

\<%= pagination\_links @member.items, offset, limit, …  
%\>

Any ideas?

Thanks,  
csn

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [November 9, 2007, 10:28pm UTC](https://www.ruby-forum.com/t/paginate-member-items/53708/2 "2007-11-09T22:28:14Z")

</div>

Hi CSN,

Any luck with a solution for this prob? I am facing the same problem  
now?

Regards,  
Sandeep G

CSN wrote:

> Is there a quick and easy way to paginate something  
> like @member.items (Member with has\_many :items)?  
> Right now I do in the controller:
> 
> @item\_pages, @member\_items = paginate :item,  
> :conditions=\>[“member\_id=?”, @member.id],  
> :per\_page=\>25,  
> :order=\>‘datetime desc’
> 
> It’d be more DRY if this was possible:
> 
> @item\_pages, @member\_items = paginate @member.items,  
> :per\_page=\>25,  
> :order=\>‘datetime desc’
> 
> And even more so if it could all be done in the  
> template:
> 
> \<% for item in @member.items(:limit=\>25,  
> :offset=\>params[:page]\*25) %\>  
> …  
> \<% end %\>
> 
> \<%= pagination\_links @member.items, offset, limit, …  
> %\>
> 
> Any ideas?
> 
> Thanks,  
> csn
> 
> * * *
> 
> Do You Yahoo!?  
> Tired of spam? Yahoo! Mail has the best spam protection around  
> [http://mail.yahoo.com](http://mail.yahoo.com)
