Find all children from related subtrees with ancestry gem

425 Views Asked by At

I have a Site Model that has_ancestry. This model hierarchy has two trees....

TREE1

SiteA (Root)

  • SiteB
  • SiteC

TREE2

SiteC (Root)

  • SiteD

Is there a method or SQL statement to show the link between SiteA and SiteD?

Or is this not possible given they exist on separate trees (associated via SiteC)?

1

There are 1 best solutions below

2
Ruby4Rails On

You can check with the while loop to go down to upwards and check until parent is nil.