映画モデルと人物モデルがあります。
映画モデルには、俳優、作家、プロデューサーのグループが必要です。
俳優、作家、プロデューサーは、すべて同じ人物モデルの人物のグループです。
これをモデル化するための最良の方法は何でしょうか?
ありがとう。
編集:各人は同時に俳優、作家、プロデューサーになることができます。そして、それらはすべて同じ属性を持っています。
編集2:私がやりたいことは次のようなものです:
Class Movie < ActiveRecord::Base
attr_accessible :name, :image, :information, :duration, :director, etc...
has_many :persons, as: :writers <-- (IDK if this is possible)
has_many :persons, as: :producers <-- (IDK if this is possible)
has_many :persons, as: :actors <-- (IDK if this is possible)
end
Class Person < ActiveRecord::Base
attr_accessible :birthdate, :birthplace, :height, :information, :name, etc..
end
ムービーモデルでグループを作成するので、次のように呼び出すことができます。
@writers = @movie.writers
@actors = @movie.actors
@producers = @movie.producers
すべてPersonオブジェクトで構成され、3つのタイプのいずれかである可能性があります。
人は他の多くの映画に関与する可能性があります。