From: Tobias Luetke Date: 2004-11-23T03:43:14+09:00 Subject: Re: rails / active record / og: question on tree structures I might have missunderstood the question, in this case just ignore me. Some code from my rails app ( AR ) model: class Category < ActiveRecord::Base belongs_to :parent, :class_name => 'Category', :foreign_key => 'parent_id' has_many :children, :class_name => 'Category', :foreign_key => 'parent_id', :dependent => true end @boards, @boots, @powder, @deepsnow are fixtures structured like this : boards \_ powder \_ deepsnow boots testcase: def test_tree assert_equal true, @boards.has_children? assert_equal false, @boots.has_children? assert_equal @boards.children, [@powder, @deepsnow] assert_equal @deepsnow.parent, @boards end On Mon, 22 Nov 2004 07:33:07 +0900, itsme213 wrote: > Does rails (or active record) have any way to conveniently define and take > advantage of the tree structure of containment? -- Tobi http://blog.leetsoft.com