There is something wrong with my associations.
I want that many VideoPost can refer to the same VideoInformation.
I then thought that the foreign key should be in VideoPost so I started with the 2 models you can see below.
But I can't access to @video_post.video_information (which seems to make sense since there is no association in VideoPost)
How should I do ? I'm a little confuse here
Thanks for any help !
My VideoPost model :
# 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
My VideoInformation model :
# 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