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.