I have many products, each product belong to one category. How can I generate each category in hyper text, and when I click on the category hyper text, I can get all the products which is belongs to this category. And ideas on that?
A:
In your controller:
@category = Category.find(params[:id])
@products = @category.products
and then in view:
<% @products.each do |p| %>
<p><%= p.name %></p>
<% end %>
klew
2010-01-08 14:37:51