Forum: Ruby on Rails has_many :through and belongs_to

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.
Chris C. (Guest)
on 2006-04-17 02:14
I have a relationship where a Show has_many Techs through People.  From
what I understand that requires me to put belongs_to Show in the People
model.  My problem is that a Tech can belong to many Shows.  Is there
any way of solving this besides putting a has_many Shows relationship in
People
Chris C. (Guest)
on 2006-04-17 02:42
Chris C. wrote:
> I have a relationship where a Show has_many Techs through People.  From
> what I understand that requires me to put belongs_to Show in the People
> model.  My problem is that a Tech can belong to many Shows.  Is there
> any way of solving this besides putting a has_many Shows relationship in
> People

After reading about these associations I realized I (think) I made an
error when making my domain model.  I have a table called shows, a table
called people, a table called techs, and a table called Castmembers.
The people table has all the information about each person.  So what I
want is to be able to say @show.techs, and get the people objects for
the techs associated with the show, plus the data in the techs table,
which contains their department and position for the show.  The sme sort
for castmembers.  I think I need a show has_many people through techs,
and a show has_many people through castmembers.  Is this right?  Then,
how do I solve the problem above with people being aassociated with
multiple shows?
This topic is locked and can not be replied to.