Forum: Ruby on Rails ActiveRecord::Associations ER diagram/macros

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
77b7cb198e0019540c96025be06f9ad7?d=identicon&s=25 Jean-marc Molina (goa103)
on 2006-05-17 12:06
Hello,

I found an interesting ER diagram on the "Module:
ActiveRecord::Associations::ClassMethods" page of the Rails Framework
Documentation :
http://ar.rubyonrails.org/classes/ActiveRecord/Ass...

At the beginning we can read « Associations are a set of macro-like
class
methods for tying objects together through foreign keys. They express
relationships like "Project has one Project Manager" or "Project belongs
to
a Portfolio". ». I would like to learn more about that concept of
expressing
relationships between objects. I only knew it as a design concept and
can't
remember seeing it applied "as this" in the source code using macros. I
find
the idea interesting. Is it some kind of Ruby "Best Practices" or
design/development pattern ?

JM.

PS : Note that the diagram is not displayed on the "official" page :
http://api.rubyonrails.org/classes/ActiveRecord/As...
I was only able to find it on that "mirror".
77b7cb198e0019540c96025be06f9ad7?d=identicon&s=25 Jean-marc Molina (goa103)
on 2006-05-17 12:09
Sorry for posting a "truncated" message but it was originally posted on
Usenet and I forgot to rewrite it.
77b7cb198e0019540c96025be06f9ad7?d=identicon&s=25 Jean-marc Molina (goa103)
on 2006-06-09 09:01
Jean-Marc Molina wrote:
> At the beginning we can read « Associations are a set of macro-like
> class methods for tying objects together through foreign keys. They
> express relationships like "Project has one Project Manager" or
> "Project belongs to a Portfolio". ».

Reading the "Simplify Business Logic with PHP DataObjects" ONLamp.com
article by Darryl Patterson I found an interesting comment about the
Class::DBI [2] Perl module : « The greatest part about it is that you
can declare relationships between classes/tables by indicating that a
certain column in your table either is a foreign key (has_a) or that
your table's primary key is referenced from another one (has_many). All
the joins will then happen behind the scenes and you can use simple
accessors to navigate your relations. ». The same terms as in the
diagram are used : "has_one", "has_many"... I know these are common
software design terms but I'm pretty sure it's not a coïncidence. I'm
about to investigate on Perl communities, stay tuned...

JM.

Notes :
* [1] <http://www.onlamp.com/pub/a/php/2004/08/05/dataobj...
* [2] <http://www.class-dbi.com>
This topic is locked and can not be replied to.