Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Associations "the rails" way...
2 Posts
Associations "the rails" way...

I have an interesting task: 3 Tables: movies,people,jobs

Every movie has many people in it and every person does a certain job (some people do more than one, and some jobs are done by more people... aka: Robert De Niro is the actor and a director, but we have several other actors in the same movie)

Here is what I need to do:

class Person < ActiveRecord::Base

has_and_belongs_to_many :movies
has_and_belongs_to_many :jobs

end class Job < ActiveRecord::Base

has_and_belongs_to_many :movies
has_and_belongs_to_many :people

end class Movie < ActiveRecord::Base

has_and_belongs_to_many :jobs
has_and_belongs_to_many :people

end

Is this sort of thing legal? I mean, do I get multiple Cartesian products that will eventually kill my application? Am I thinking the right way at all?

Thanx for any input.

This might be a simple user->role->permission type setting. I can pick up that from a tutorial. But... really I need a deffinate combo of the three. So... If I have a movie with a director, theoretically there can be as many directors to this movie as there are persons, who are directors... I need jut THE ONE. So I need a movies_jobs_persons table I guesss...

2 Posts
Login to add your message