Shoppe gem each method on product categories

153 views Asked by At

Just wondering if anyone with any experience with Shoppe know how to call an each method on product categories?

I'm trying to do something like this :

<% Shoppe::ProductCategory.each do |prod| %>
   <li><%= prod.name %></li>
<% end %>

but I'm getting an undefined method error. Is there some special method that I'm missing? Shoppe::ProductCategory.all and Shoppe::ProductCategory.first.name both have no problems.

Thanks!

solved

Beautiful, @zoran, beautiful.

1

There are 1 answers

1
Zoran On BEST ANSWER

Try rewriting it to this instead:

 <% Shoppe::ProductCategory.all.each do |prod| %>
   <li><%= prod.name %></li>
 <% end %>

You need to call all on the Shoppe::ProductCategory to be able to iterate over the collection.

Hope it helps!