I want to implement a tree menu (simple example of tree menu) in a Rails app that I am working on. I am unsure of whether to use acts_as_tree or Ancestry. Its seems that it would be easier to implements a simple tree menu using acts_as_tree, however, Ancestry is more popular and regularly maintained. Does anyone have any thoughts on this?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- Is there a way to remove IDV Tags from an AIFF fil
- Rails how to handle error and exceptions in model
相关文章
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
- form_for wrong number of arguments in rails 4
- Rspec controller error expecting <“index”> but
- Factory_girl has_one relation with validates_prese
Use ancestry. It has more powerful query capabilities as it implements the materialized path pattern, as opposed to acts_as_tree that implements adjacency list.
There are other options too, like nested set, but materialized path is usually the most comprehensive.
https://communities.bmc.com/communities/docs/DOC-9902
If you need to sort in preorder at DB level (for example a paginated tree-grid, a preloaded menu that you iterate and indent/dedent according to the depth in tree for displaying) you need to either use a recursive query, or sortable encoding like nested set or nested interval. (That is if sorting in memory is not an option, and it almost never is.)
https://github.com/collectiveidea/awesome_nested_set
https://github.com/clyfe/acts_as_nested_interval
Each has ups and downs. Choose your what fits you.