HI all, newbie question, I have the following DB Structure
actors
movie
role
- id
- name
- requiresSwimming
- requiresHorseskills
movie_actor
- actor_id
- movie_id
- role_id
How should I map this in my model in rails? An actor can only have
one role in each movie
Thanks J
It makes a little more sense to me to have the db look like this:
actor
movie
role
- actor_id
- movie_id
- requires_swimming
- requires_horsemanship
Then your models would look like this
class Actor < ActiveRecord::Base
has_many :roles
has_many :movies, :through => :roles
end
class Movie < ActiveRecord::Base
has_many :roles
has_many :actors, :through => :roles
end
class Role < ActiveRecord::Base
belongs_to :actor
belongs_to :movie
end
–
Building an e-commerce site with Rails?
http://www.agilewebdevelopment.com/rails-ecommerce
Meet up at RailsConf:
http://railsconf2007.conferencemeetup.com/
Lol? Why did you post that qeustion again? i answered your first
thread 1 hour ago?