You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -319,6 +319,7 @@ When you include ```has_closure_tree``` in your model, you can provide a hash to
319
319
* ```nil``` does nothing with descendant nodes
320
320
* ```:name_column``` used by #```find_or_create_by_path```, #```find_by_path```, and ```ancestry_path``` instance methods. This is primarily useful if the model only has one required field (like a "tag").
321
321
* ```:order``` used to set up [deterministic ordering](#deterministic-ordering)
322
+
* ```:scope``` restricts root nodes and sibling ordering to specific columns. Can be a single symbol or an array of symbols. Example: ```scope: :user_id``` or ```scope: [:user_id, :group_id]```. This ensures that root nodes and siblings are scoped correctly when reordering. See [Ordering Roots](#ordering-roots) for more details.
322
323
* ```:touch``` delegates to the `belongs_to` annotation for the parent, so `touch`ing cascades to all children (the performance of this for deep trees isn't currently optimal).
323
324
324
325
## Accessing Data
@@ -491,9 +492,30 @@ table. So for instance if you have 5 nodes with no parent, they will be ordered
491
492
If your model represents many separate trees and you have a lot of records, this can cause performance
492
493
problems, and doesn't really make much sense.
493
494
494
-
You can disable this default behavior by passing `dont_order_roots: true` as an option to your delcaration:
495
+
You can scope root nodes and sibling ordering by passing the `scope` option:
0 commit comments