问题
So I'm looking for a gem that will bring some tree behavior to the pages model.
From what I can see there are quite a few, I was wondering what other people thought.
If there any great ones or and dodgy ones to avoid.
Cheers.
回答1:
Take a look at Ancestry, it's remarkably efficient.
回答2:
I recommend Closure Tree. His author introduces good resources and reasons for it here.
回答3:
check out here
https://www.ruby-toolbox.com/categories/Active_Record_Nesting
I prefer awesome_nested_set
回答4:
Seems like the most popular is AwesomeNestedSet https://github.com/collectiveidea/awesome_nested_set
It has categories ordering system, what is missing in others and all standart functions. Setup is pretty well docummented
回答5:
I have implemented acts_as_tree
successfully for some threaded comments, but am not impressed by its performance-handling. It was very simple to implement, though.
By default, it now queries the database once for every node in the tree. I suspect with some clever settings and some optimisation this can be solved though, but, out of the box: not too impressed.
来源:https://stackoverflow.com/questions/5474402/rails-3-whats-the-best-act-as-tree-behavior