Organise ActiveRecord model into a tree structure
Making some guesses about what you’re trying to do, you’ll have to alter the table schema to do this efficiently. The ‘ancestry’ gem (https://github.com/stefankroes/ancestry ) can do the migration and update your parent_id-based data to enable all its cool features.
Active record: how to recursively load children of children of children in one query?
2 projects | reddit.com/r/rails | 1 Apr 2022
1 project | reddit.com/r/rubyonrails | 12 Jan 2022
Hierarchical Structures in PostgreSQL
2 projects | news.ycombinator.com | 25 Jun 2021
How to query Ancestry fast
1 project | dev.to | 29 Apr 2021
Saving ancestry children on update
1 project | reddit.com/r/rails | 3 Mar 2021