Sha256: 83fe7416898dbbafa3d1cff81c00d8ab98ea631e2629bd226dd622a14c274d2f
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module SortableNestedSetHelper def sns_tree(class_or_category) if class_or_category.is_a?(Class) @category_class = class_or_category @categories = @category_class.includes(@category_class.sns_items_type) else @category_class = class_or_category.class @categories = class_or_category.self_and_descendants.includes(@category_class.sns_items_type) end render 'sortable_nested_set/tree', :category_class => @category_class, :categories => @categories.arrange end def sns_lineage(category, options={}) content_for :head do stylesheet_link_tag 'sortable_nested_set' end ancestors = category.send(options[:include_self] ? :self_and_ancestors : :ancestors) links = ancestors.select([:id, :name]).collect do |c| link_to c.name, c, :class => :lineage end content_tag :p, links.join.html_safe unless links.empty? end def sns_options(category_class, mover=nil) sorted_nested_set_options(category_class, lambda(&:left_column_name), mover) { |cat, lvl| "#{'.'*lvl}#{cat}" } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sortable_nested_set-0.3.0 | app/helpers/sortable_nested_set_helper.rb |