Methods
Public Instance methods
Returns list of ancestors, starting from parent until root.
subchild1.ancestors # => [child1, root]
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 69 69: def ancestors 70: node, nodes = self, [] 71: nodes << node = node.parent until not node.has_parent? 72: nodes 73: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 75 75: def root 76: node = self 77: node = node.parent until not node.has_parent? 78: node 79: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 85 85: def self_and_siblings 86: has_parent? ? parent.children : self.class.roots 87: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 81 81: def siblings 82: self_and_siblings - [self] 83: end