Venu Vallayil wrote:
Can somebody give me what could be the structure and content of
locations table, if that is to be defined as acts_as_tree?
Your help is appreciated and thanks in advance.
class Location < ActiveRecord::Base
acts_as_tree :order => “location_name”
all you need is a
“parent_id” column in the table/model. dat’s it. you’ll gain the
location.ancestors # all parents of object
location.root # returns the first first parent in the leaf
location.self_and_siblings # the same generation of objects
location.siblings # same generation, excluding the location object
location.parent # the direct parent of the location object
location.children # the direct children of the location object or an
empty array if no children exist