Methods
A
R
S
Instance Public methods
ancestors()

Returns list of ancestors, starting from parent until root.

subchild1.ancestors # => [child1, root]
# 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
root()

Returns the root node of the tree.

# File rails/activerecord/lib/active_record/acts/tree.rb, line 74
def root
  node = self
  node = node.parent while node.parent
  node
end
self_and_siblings()

Returns all siblings and a reference to the current node.

subchild1.self_and_siblings # => [subchild1, subchild2]
# File rails/activerecord/lib/active_record/acts/tree.rb, line 90
def self_and_siblings
  parent ? parent.children : self.class.roots
end
siblings()

Returns all siblings of the current node.

subchild1.siblings # => [subchild2]
# File rails/activerecord/lib/active_record/acts/tree.rb, line 83
def siblings
  self_and_siblings - [self]
end