itsme213 wrote:

 > Does rails (or active record) have any way to conveniently define and 
take
 > advantage of the tree structure of containment?
 >
 >   e.g. a Modules contains Name, Modules and Classes.
 >
 >   A Class contains Name, Attributes.
 >
 >   An Attribute contains a Name and a Type.
 >
 > The tree-like containment relations can be exploited more (certainly
 > differently) from non-tree relationships (e.g. a Module imports other
 > Modules, a Class inherits a Class).


Funny, that's what I was thinking about today, too. By managing tree 
structures you probably mean all kinds of hierarchical data and the ways 
this data gets managed and stored in the database. There are usually 2 
ways of doing this. The "The Adjacency List Model" and the "Modified 
Preorder Tree Traversal". Both nicely explained in this article: 
http://www.sitepoint.com/print/hierarchical-data-database (with php as 
its example language)

I was asking on #rubyonrails IRC-channel today, if there was an 
implementation in Ruby I could learn from, because I am working on a CMS 
which stores its data in tree form, much like a forum. Someone pointed 
me to RForum, which is developed using Rails. Their source code reads 
nicely (so, nice that I think I going to borrow some of it ;) RForum 
uses a variation of the Preorder Tree Traversal algo. You can see how it 
works here:

http://rforum.andreas-s.net/trac/file/rforum/app/models/post.rb

and you wanna look at the database structure here:

http://rforum.andreas-s.net/trac/file/rforum/db/production_structure.sql

But back to your question. I think it would be great if there was 
support for this as a module (if this can be a module/library to Rails). 
Actually coding something something with trees always costs me a lot of 
time (when coding cmss or forumsoftware and the likes) and it would be 
great if this kind of functionality could simply be dropped into your 
Rails app. At the moment it just looks like I am going to copy some of 
their code and customize it to my purposes. I have barely thought about 
how to generalize this to make a (datastore) plugin out of it. Maybe 
someone else already  has?

-- 
Sascha Ebach