Methods
- A
- R
- S
Instance Public methods
Returns list of ancestors, starting from parent until root.
subchild1.ancestors # => [child1, root]
Source: show
# File rails/activerecord/lib/active_record/acts/tree.rb, line 67 def ancestors node, nodes = self, [] nodes << node = node.parent while node.parent nodes end
Returns the root node of the tree.
Source: show
# File rails/activerecord/lib/active_record/acts/tree.rb, line 74 def root node = self node = node.parent while node.parent node end
Returns all siblings and a reference to the current node.
subchild1.self_and_siblings # => [subchild1, subchild2]
Source: show
# File rails/activerecord/lib/active_record/acts/tree.rb, line 90 def self_and_siblings parent ? parent.children : self.class.roots end
Returns all siblings of the current node.
subchild1.siblings # => [subchild2]
Source: show
# File rails/activerecord/lib/active_record/acts/tree.rb, line 83 def siblings self_and_siblings - [self] end