HI all, newbie question, I have the following DB Structure actors - id - name - age movie - id - name - year 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
on 2007-02-20 02:07
on 2007-02-20 15:18
It makes a little more sense to me to have the db look like this: actor - id - name - birth_date movie - id - name - year 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/
on 2007-02-20 15:27
Lol? Why did you post that qeustion again? i answered your first thread 1 hour ago?