Forum: Ruby on Rails How do I define a multi-layer aggregation structure?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
1292dfc5df2064e008f7f12b9c56561d?d=identicon&s=25 allen (Guest)
on 2007-04-11 14:03
(Received via mailing list)
Hi all,

I've posted this question before. Someone told me to see the RDoc of
ActiveRecord::Associations::ClassMethods, but I cannot find any
related information about multi-layer aggregation in this document.

This is what I'm doing now:
A "material" has "mechanical_feature", "chemistry_feature",
"physical_feature" and "technical_feature". Each of these features has
different amount of properties such as "elastic_modulus". I put all
these properties in the "material" table and use aggregation to
achieve the object model "material.mechanical_feature". So "material"
extends "ActiveRecord::Base", other composited classes
don't."mechanical_feature" has a series of "hardness" properties like
"rockwell_hardness", "shore_hardness", etc. They are mapping to the
corresponding columns of "material" table, of course. I'm thinking
that I should create a class "hardness" and put all these kind of
properties into it so that I can use
"material.mechanical_feature.hardness.rockwell" in my ruby code.

My question is that:
Since "mechanical_feature" is a composite class which doesn't extend
"ActiveRecord::Base", I suppose it cannot use the "composed_of"
method. Then how can I make "hardness" class aggregation? Some folks
told me that multi-layer aggregation is a ruby best-practice. Then how
can I achieve this?

Thanks a lot!
This topic is locked and can not be replied to.