Welcome to Better Nested Set for Ruby on Rails
This is a plugin to replace acts_as_nested_set and ehance it.
What is nested set ?
It's a great and smart way to represent ordered trees into a table. Joe Celko explained this solution in a famous article in 1996.
What is it useful for ?
Categories, or menus, are often organized as ordered trees. Rails provides the good acts_as_tree, but it cannot handle easily ordered trees, and is heavily recursive. Nested set provides a clean way to retrieve tree parts in a single query. It's longer to insert than with acts_as_tree, but faster to retrieve.
Why extend acts_as_nested_set ?
The nested set proposed in rails is not well suited for many usages; it misses many useful methods. I needed menus and categories systems in some projects, with navigation methods like level, full_set, siblings, children... and move_to methods.
How to install ?
It's a plugin. You have to copy the code into vendor/plugins of your project. You can retrieve it via svn:
Last stable release:
script/plugin install svn://rubyforge.org/var/svn/betternestedset/tags/stable/betternestedset
or if you want to use the last development version:
script/plugin source svn://rubyforge.org/var/svn/betternestedset/trunk script/plugin install betternestedset
Another method is to set an external reference to the plugin if you project is versioned with svn:
svn propset svn:externals 'betternestedset svn://rubyforge.org/var/svn/betternestedset/tags/release-0.1' vendor/plugins
How does it work ?
See some examples. See how to display a recursive menu. See the api.
License
BetterNestedSet? is released under the MIT license.
Errors, suggestions
Join us on the mailing list betternestedset-talk.
Feel free to fill in tickets. Due to spam, you need to login : use rails and better_nested_set.
I'm sometimes on freenode irc #rubyonrails too, nick jcm. Thank you for your input !
