acts_as_tree
acts_as_tree: http://snippets.dzone.com/tag/acts_as_tree ------------ // This takes a collection of acts_as_tree objects and creates a unordered list. // // Put this in your helper: [code="ruby"] def tree_ul(acts_as_tree_set, init=true, &block) if acts_as_tree_set.size > 0 ret = '
- ' acts_as_tree_set.collect do |item| next if item.parent_id && init ret += '
- ' ret += yield item ret += tree_ul(item.children, false, &block) if item.children.size > 0 ret += '' end ret += '
' end end [/code] // ... and this in your view: [code="ruby"] <%= tree_ul(@acts_as_list_collection) {|item| link_to h(item.name), :action => 'edit', :id => item } %> [/code]