Module: Admin::TaxonsHelper

Defined in:
app/helpers/admin/taxons_helper.rb

Instance Method Summary collapse

Instance Method Details

#taxon_path(taxon) ⇒ Object



2
3
4
# File 'app/helpers/admin/taxons_helper.rb', line 2

def taxon_path(taxon)
  taxon.ancestors.reverse.collect { |ancestor| ancestor.name }.join( " >> ")
end

#taxons_checkbox_tree(root, product) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/admin/taxons_helper.rb', line 6

def taxons_checkbox_tree(root, product)
  return '' if root.children.blank?
   'ul' do
    root.children.map do |taxon|
       'li' do
        [check_box_tag("taxon_ids[]", taxon.id, product.taxons.include?(taxon), :id => "taxon_ids_#{taxon.id}"),
         label_tag("taxon_ids_#{taxon.id}", taxon.name)].join(' ').html_safe +
        taxons_checkbox_tree(taxon, product)
      end.html_safe
    end.join("\n").html_safe
  end
end