coming from awesome_nested_set we use lft for ordering.
i checked the rebuild! method and it looks like it's calling children which then might be rendered randomly by our DB.
we then recreate the tree for each children, but this means that the position might change.
children.find_each { |c| c.rebuild!(true) }
https://github.com/ClosureTree/closure_tree/blob/07f4dfdac48765a60a786a5dfedaffb1d1e242be/lib/closure_tree/hierarchy_maintenance.rb#L65:L89
example
before:
1, lft: 1, position: nil
2, lft: 5, position: nil
3, lft: 4, position: nil
4, lft: 3, position: nil
5, lft: 2, position: nil
If we call .children we might get in return 1,2,3,4,5 but we actually want to get 1,5,4,3,2.
the tree then could be created like
1, lft: 1, position: 1
2, lft: 5, position: 2
3, lft: 4, position: 3
4, lft: 3, position: 4
5, lft: 2, position: 5
coming from
awesome_nested_setwe uselftfor ordering.i checked the
rebuild!method and it looks like it's calling children which then might be rendered randomly by our DB.we then recreate the tree for each children, but this means that the position might change.
children.find_each { |c| c.rebuild!(true) }https://github.com/ClosureTree/closure_tree/blob/07f4dfdac48765a60a786a5dfedaffb1d1e242be/lib/closure_tree/hierarchy_maintenance.rb#L65:L89
example
before:
If we call
.childrenwe might get in return1,2,3,4,5but we actually want to get1,5,4,3,2.the tree then could be created like