私の協会に何か問題があります。
多くのVideoPostが同じVideoInformationを参照できるようにしたいと思います。次に、外部キーをVideoPostに含める必要があると考えたので、以下に示す2つのモデルから始めました。しかし、@ video_post.video_informationにアクセスできません(VideoPostには関連付けがないため、これは理にかなっているようです)
どうすればよいですか?私はここで少し混乱しています
助けてくれてありがとう!
私のVideoPostモデル:
# Table name: video_posts
#
# id :integer not null, primary key
# user_id :integer
# video_information_id :integer
# created_at :datetime not null
# updated_at :datetime not null
class VideoPost < ActiveRecord::Base
belongs_to :user
attr_accessible :video_information_id
end
私のVideoInformationモデル:
# Table name: video_informations
#
# id :integer not null, primary key
# title :string(255)
# description :text
# keywords :text
# duration :integer
# video_url :string(255)
# thumbnail_small :string(255)
# thumbnail_large :string(255)
# created_at :datetime not null
# updated_at :datetime not null
class VideoInformation < ActiveRecord::Base
has_many :video_posts
end