# Paginator within a paginator

**URL:** <https://www.ruby-forum.com/t/paginator-within-a-paginator/119080>\
**Category:** Rails\
**Created:** [November 2, 2007, 10:17pm UTC](https://www.ruby-forum.com/t/paginator-within-a-paginator/119080 "2007-11-02T22:17:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [November 2, 2007, 10:17pm UTC](https://www.ruby-forum.com/t/paginator-within-a-paginator/119080/1 "2007-11-02T22:17:02Z")

</div>

Hello,

Within an action called “view” that is associated with a view of  
product listings, I render a product partial based on a product object  
that that looks like this:

@product\_pages, @products = paginate(:products,  
:conditions =\> [“search\_term\_id = ?”, search\_term\_id],  
:per\_page =\> 10)

My products table has\_many features. I would like to call a “features”  
partial, with a paginated list of features within my products partial,  
but I cannot figure out how to do that. Because if I have a @features  
object within my “view” action, I cannot figure out how to get just  
the features that are related to a given product.

So, I’m iterating through my @products object in my view:

\<% for p in @products %\>  
\<%= p.title %\>  
\<%= render :partial =\> “features” %\>  
\<% end %\>

But if I define an object @features in my view action, that object  
must have all features for all products. Because I hit that view  
action, and I have to instantiate that @features object with what i’ve  
got – before I iterate through @products. And, I don’t want to go  
back and do a separate database query for each product – at least I  
don’t think I do.

Help appreciated.

Charlie
