I'm having trouble showing my view correctly. I have this as my code right now:
<% for store in @stores %>
<% store.name %>
<% @stores.products.each do |p| %>
<% p.name %>
<% end %>
<% end %>
def index
@stores = Store.paginate(:page => params[:page], :per_page => 20)
end
But end up with the error:
undefined method `products'
I'm trying to show a store and then all of its products, repeating this on the same page as much as possible e.g:
Store1
Product1
Product2
Store2
Product1
Product2
Product3
Product4
How can I do this?