Module: Comable::ProductsHelper

Defined in:
app/helpers/comable/products_helper.rb

Instance Method Summary collapse

Instance Method Details



11
12
13
14
15
16
17
# File 'app/helpers/comable/products_helper.rb', line 11

def link_to_category(category, force_link: false)
  if force_link || @category != category
    link_to category.name, comable.products_path(category_id: category.id)
  else
    category.name
  end
end

#listed_categories(categories, options = {}) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/comable/products_helper.rb', line 3

def listed_categories(categories, options = {})
  (options[:tag] || :ul, class: options[:class]) do
    categories.map do |category|
      (:li, link_to_category(category), class: "#{'active' if @category == category}")
    end.join.html_safe
  end
end

#sku_table(product, options = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'app/helpers/comable/products_helper.rb', line 19

def sku_table(product, options = nil)
  stocks = product.stocks
  (:table, nil, options) do
    html = ''
    html << build_sku_v_table_header(product, stocks)
    html << build_sku_table_rows(product, stocks)
    html.html_safe
  end
end