| 32 | | # * siblings : Returns all the children of the parent, excluding the current node ([ subchild2 ] when called from subchild1) |
|---|
| 33 | | # * self_and_siblings : Returns all the children of the parent, including the current node ([ subchild1, subchild2 ] when called from subchild1) |
|---|
| 34 | | # * ancestors : Returns all the ancestors of the current node ([child1, root] when called from subchild2) |
|---|
| 35 | | # * root : Returns the root of the current node (root when called from subchild2) |
|---|
| | 32 | # * siblings : Returns all the children of the parent, excluding the current node |
|---|
| | 33 | # ([ subchild2 ] when called from subchild1) |
|---|
| | 34 | # * self_and_siblings : Returns all the children of the parent, including the current node |
|---|
| | 35 | # ([ subchild1, subchild2 ] when called from subchild1) |
|---|
| | 36 | # * ancestors : Returns all the ancestors of the current node |
|---|
| | 37 | # ([child1, root] when called from subchild2) |
|---|
| | 38 | # * root : Returns the root of the current node |
|---|
| | 39 | # (root when called from subchild2) |
|---|
| 40 | | # * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet. |
|---|
| 41 | | # * <tt>counter_cache</tt> - keeps a count in a children_count column if set to true (default: false). |
|---|
| | 48 | # * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet |
|---|
| | 49 | # * <tt>counter_cache</tt> - keeps a count in a children_count column if set to true (default: false) |
|---|
| | 50 | # |
|---|
| | 51 | # ==== Examples |
|---|
| | 52 | # |
|---|
| | 53 | # class Category < ActiveRecord::Base |
|---|
| | 54 | # acts_as_tree :order => "name" |
|---|
| | 55 | # end |
|---|
| | 56 | # |
|---|
| | 57 | # # Gives: |
|---|
| | 58 | # root = Category.create(:name => "root") |
|---|
| | 59 | # child1 = root.children.create(:name => "child1") |
|---|
| | 60 | # subchild1 = child1.children.create(:name => "subchild1") |
|---|
| | 61 | # |
|---|
| | 62 | # # If your 'parent_id' field is named differently and you have a column called 'children_count' |
|---|
| | 63 | # class Category < ActiveRecord::Base |
|---|
| | 64 | # acts_as_tree :order => "name", :foreign_key => 'related_id', :counter_cache => true |
|---|
| | 65 | # end |
|---|
| | 66 | # |
|---|