Part model question


#1

Is parts model only used to link Movie to Actor?

For example, a movie may have many parts, as in has many scenes. Also an actor can have many parts in a movie. Does this have anything to do with the model, or is it strictly to link Movie to Actor?

Furthermore, can we use any name to link Movie to Actor. For example, instead of part model could we name it connect model? Can we instead do something like in the Example below...

#model Actor
    class Actor < ActiveRecord::Base
    	has_many :connects
    	has_many :movies, through: :connects
    end

#model Movie
    class Movie < ActiveRecord::Base
    	has_many :connects 
    	has_many :actors, through: :connects
    end


#model Connect
    class Connect < ActiveRecord::Base
    	belongs_to :movie #singular
    	belongs_to :actor #singular
    end

#2

Hi Jay,

I think the answer to your question is “yes”, but I'm not completely sure I understand it. Could you try rephrasing, please?

Thanks :slight_smile:


#3

Thanks Zeke,

To reiterate my question in summary form...

  1. Does the parts model need to be named parts model? Could we name it a different name instead?
  2. Is the parts model only used to connect movies to actors or is there more to it than just that? I'm getting a bit crossed up because I'm think for example a part in a movie. Perhaps I'm over thinking it.

Thanks!


#4

@jaydacoder

  1. Yes
  2. I think the part model is used to connect actors to specific parts in the movie, so there's a little more to it than just what you said, but really not much more.

#5

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.