Forum: Ruby on Rails relations between contact_person and contact_business

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.
Trom T. (Guest)
on 2009-05-07 21:11
Hello all,

i am stuck with something.

i have the following situation:

[code=]contacts---|
           |--|0-1|--contact_businesses
           |         (either one of booth; business or contact)
           |--|0-1|--contact_people[/code]
i have a contacts model that either extends to contact_business or
contact_person, depending if its a person or a business.
now i whant to describe relationships between people and businesses.
i thought about something like this:
[code=]contacts---|
           |--|0-1|--contact_businesses
           |         (either one of booth; business or contact)
           |--|0-1|--contact_people
           |
           |--|0-n|--contact_relations (contact_person_contact_id,
contact_business_contact_id)[/code]
so contact_relations would store the contact_id of the file that is
create/edited depending if it is a business or a person in
contact_business_contact_id or contact_person_contact_id and the
contact_id of the relation (wich must be the other kind) in the other
field.
this would be the way i would do it by hand, if i would have programmed
this in php. but in ror i dont really know or understand how this is t
be accomplished.

maybe self joins is the solution
(http://guides.rubyonrails.org/association_basics.h...). but
somehow i dont understand how this works and what table collums i would
need.

can somebody help me?

thanks a lot,

togo123
This topic is locked and can not be replied to.