ruby-on-railsactiverecordancestry

Rails Ancestry: How do I get descendants that are at depth of n of a subtree?


I have a node which descendants I am interested in. But I am interested in descendants that are found at a specific depth. How do I do that?


Solution

  • https://github.com/stefankroes/ancestry#selecting-nodes-by-depth

    Use the at_depth(n)
    
    n being the depth of the nodes that you want to return
    
    Note: the depth begins with value 0```