bisscomm/refinerycms-products

View on GitHub
app/views/refinery/products/shared/_product.html.erb

Summary

Maintainability
Test Coverage
<% root_category = product.categories.select{ |c| c.root? } %>

<li id=<%= "product_#{product.id}" %> class="product">
  <div class="title">
    <h2><%= link_to product.title, refinery.products_product_path(product, referer: refinery.products_category_path(root_category)) %></h2>
  </div>

  <div class="image">
    <%= link_to refinery.products_product_path(product, referer: refinery.products_category_path(root_category)) do %>
      <%= image_fu product.images.first, '242x200#c' %>
    <% end %>
  </div>

  <div class="sub-category">
    <%= product.categories.select{ |c| c.leaf? }.first.try(:title) %>
  </div>

  <ul class="properties">
    <% product.propertizations.each do |property| %>
      <li>
        <span class="title"><%= Refinery::Products::Property.find_by(id: property.products_property_id).title %></span>
        <span class="value"><%= property.value  %></span>
      </li>
    <% end %>
  </ul>

  <%= link_to t('.read_more', product: product.title).html_safe, refinery.products_product_path(product, referer: refinery.products_category_path(root_category)), class: 'read-more' %>
</li>