Closed DenisRomanovsky closed 9 years ago
try this :
<%= product.categories.select{ |c| c.leaf? }.first.try(:title) %>
or
<div class="sub-category">
<%= if product.categories.select{ |c| c.leaf? } %>
<%= product.categories.select{ |c| c.leaf? }.first.title %>
<% else %>
<%= product.categories.first.title %>
<% end %>
</div>
It's not really clean but it will help you.
This works for me, thank you.
Fixed with bae77c87b59f238d3e7e40ba916f4428fb2af85d
Steps to reproduce:
Result -- An error happens :
Now if to mark the product with sub. category, everything works fine.
Gemfile:
Full Trace: