Forum: Ruby on Rails ternary associations

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.
33ada38869e3bd882cfbe6799b5c822b?d=identicon&s=25 jduflost (Guest)
on 2005-11-16 11:41
(Received via mailing list)
Hello all,

Does anybody know how I can handle ternary associations with rails ?
Could
you give me an example ?

Thank you.

Johan

Johan Duflost
Analyst Programmer
Belgian Biodiversity Platform ( http://www.biodiversity.be)
Belgian Federal Science Policy Office (http://www.belspo.be )
Tel:+32 2 650 5751 Fax: +32 2 650 5124
B9a732fc30c32098347a0177c75ee27b?d=identicon&s=25 jeroen (Guest)
on 2005-11-16 12:24
(Received via mailing list)
johan duflost wrote:

>
> Hello all,
>
> Does anybody know how I can handle ternary associations with rails ?
> Could you give me an example ?
>
What's a ternary association?

Jeroen
82476266af9d460415d8f1fc16bb54ed?d=identicon&s=25 jarkko (Guest)
on 2005-11-16 13:21
(Received via mailing list)
On 16.11.2005, at 12.38, johan duflost wrote:

>
> Hello all,
>
> Does anybody know how I can handle ternary associations with
> rails ? Could you give me an example ?

Hi Johan,

Give the "association" a class of its own. I'm running out of good
examples (this one's a bit on the cynical side) but here goes anyway:

Bride has_many :weddings
Groom has_many :weddings
Church has_many :weddings

Wedding
	belongs_to :bride
	belongs_to :groom
	belongs_to :church

Here the wedding is the "association". But as it's also a class, it
is a lot more flexible than a simple association. And no, there is no
way to build a ternary (or any other n-ary, n>2) "dummy" relationship
á la has_and_belongs_to_many.

//jarkko
33ada38869e3bd882cfbe6799b5c822b?d=identicon&s=25 jduflost (Guest)
on 2005-11-16 13:24
(Received via mailing list)
It's a join table that links three tables. Often a join table links only
two
and all examples are based on this assumption.

model1_id    model2_id    model3_id   additional_attribute1
additional_attribute2 ....

Johan


----- Original Message -----
From: "Jeroen Houben" <jeroen@terena.nl>
To: <rails@lists.rubyonrails.org>
Sent: Wednesday, November 16, 2005 12:21 PM
Subject: Re: [Rails] ternary associations - Checked by AntiVir DEMO
version -
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 christopher.k.hall (Guest)
on 2005-11-16 13:27
(Received via mailing list)
a ternary association is a 3-way association or relationship between
objects, as opposed to a binary (2-way) which you see in Rails, or
quaternary (4-way), and so on....

now, whether Rails does 3-ary i have no idea. i haven't seen any
documentation on it, so i would assume no, however, don't take that as
the
definitive answer.
This topic is locked and can not be replied to.