Sha256: c19945a82c216fd39b534a38de0d7969c8294c7f31dc386bb4e6ed561d86ef7e
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'awesome_nested_set/helper' include CollectiveIdea::Acts::NestedSet::Helper module SortableNestedSetHelper def sortable_nested_set_tree(class_or_category) if class_or_category.is_a?(Class) @category_class = class_or_category @categories = class_or_category.all(:include => class_or_category.sns_items_type, :order => :lft) else @category_class = class_or_category.class @categories = class_or_category.self_and_descendants_with_items @root = class_or_category end @sortable_ids = @categories.collect(&:id) render 'sortable_nested_set/tree', :category_class => @category_class, :categories => @categories, :sortable_ids => @sortable_ids, :root => @root end def sns_lineage(category, options=Hash.new) content_tag :p, category.lineage(options).collect { |a| link_to(a.name, a) } .join(image_tag('folder_closed.png', :class => :descent)).html_safe end def sns_options(class_or_category, mover=nil) nested_set_options(class_or_category, mover) do |category, descendants, level| "#{'.' * level} #{category.name}" end end end ActionView::Base.send :include, SortableNestedSetHelper
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sortable_nested_set-0.1.26 | app/helpers/sortable_nested_set_helper.rb |