From be47a4bbeac59d85af16b5e83e10ff242628519d Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 29 Jan 2009 22:12:11 +0100 Subject: added node model to make basic functional tests pass. added awesome_nested_set plugin --- vendor/plugins/awesome_nested_set/README.rdoc | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 vendor/plugins/awesome_nested_set/README.rdoc (limited to 'vendor/plugins/awesome_nested_set/README.rdoc') diff --git a/vendor/plugins/awesome_nested_set/README.rdoc b/vendor/plugins/awesome_nested_set/README.rdoc new file mode 100644 index 00000000..c093f751 --- /dev/null +++ b/vendor/plugins/awesome_nested_set/README.rdoc @@ -0,0 +1,64 @@ += AwesomeNestedSet + +Awesome Nested Set is an implementation of the nested set pattern for ActiveRecord models. It is replacement for acts_as_nested_set and BetterNestedSet, but awesomer. + +== What makes this so awesome? + +This is a new implementation of nested set based off of BetterNestedSet that fixes some bugs, removes tons of duplication, adds a few useful methods, and adds STI support. + +== Installation + +If you are on Rails 2.1 or later: + + script/plugin install git://github.com/collectiveidea/awesome_nested_set.git + +== Usage + +To make use of awesome_nested_set, your model needs to have 3 fields: lft, rgt, and parent_id: + + class CreateCategories < ActiveRecord::Migration + def self.up + create_table :categories do |t| + t.string :name + t.integer :parent_id + t.integer :lft + t.integer :rgt + end + end + + def self.down + drop_table :categories + end + end + +Enable the nested set functionality by declaring acts_as_nested_set on your model + + class Category < ActiveRecord::Base + acts_as_nested_set + end + +Run `rake rdoc` to generate the API docs and see CollectiveIdea::Acts::NestedSet::SingletonMethods for more info. + +== View Helper + +The view helper is called #nested_set_options. + +Example usage: + + <%= f.select :parent_id, nested_set_options(Category, @category) {|i| "#{'-' * i.level} #{i.name}" } %> + + <%= select_tag 'parent_id', options_for_select(nested_set_options(Category) {|i| "#{'-' * i.level} #{i.name}" } ) %> + +See CollectiveIdea::Acts::NestedSet::Helper for more information about the helpers. + +== References + +You can learn more about nested sets at: + + http://www.dbmsmag.com/9603d06.html + http://threebit.net/tutorials/nestedset/tutorial1.html + http://api.rubyonrails.com/classes/ActiveRecord/Acts/NestedSet/ClassMethods.html + http://opensource.symetrie.com/trac/better_nested_set/ + + +Copyright (c) 2008 Collective Idea, released under the MIT license \ No newline at end of file -- cgit v1.3