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
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
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 -- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
johan duflost
2005-Nov-16 12:22 UTC
Re: ternary associations - Checked by AntiVir DEMO version -
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-aHd7JyfBtzlmR6Xm/wNWPw@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Wednesday, November 16, 2005 12:21 PM Subject: Re: [Rails] ternary associations - Checked by AntiVir DEMO version -> 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 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
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. On 11/16/05, Jeroen Houben <jeroen-aHd7JyfBtzlmR6Xm/wNWPw@public.gmane.org> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails