Railsの初心者として、私は自分の問題を解決する方法を見つけることができません^^
ビデオのURLを含むテキストフィールドを持つフォームからVideoPostを作成したい(YouTubeなど)
宝石のおかげでビデオに関する情報を取得していますhttps://github.com/thibaudgg/video_info
そして、私のモデル (VideoInformation) を使用してそれらの情報を保存したいと思います。しかし、作成プロセスがどのように機能するかわかりません。
助けてくれてありがとう!
次のように VideoPostsController で VideoPost を作成しようとしています:
def create
video_info = VideoInfo.new(params[:video_url])
video_information = VideoInformation.create(video_info) #undefined method `stringify_keys' for #<Youtube:0x00000006a24120>
if video_information.save
@video_post = current_user.video_posts.build(video_information)
end
end
私の 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
私の VideoInformation モデル (VideoInfo gem と同じ属性名を取得):
# 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