Acts As Ordered Tree plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install svn://rubyforge.org/var/svn/ordered-tree/acts_as_ordered_tree
class Person < ActiveRecord::Base acts_as_ordered_tree :foreign_key => :parent_id, :order => :position end class CreatePeople < ActiveRecord::Migration def self.up create_table :people do |t| t.column :parent_id ,:integer ,:null => false ,:default => 0 t.column :position ,:integer end add_index(:people, :parent_id) end end
Which "in effect" sets up the following:
belongs_to :parent,
:class_name => Person,
:foreign_key => :parent_id
has_many :children,
:class_name => Person,
:foreign_key => :parent_id,
:order => :position
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, 11 months ago

