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