create a model in create action from a class
- by Pontek
As a newbie to rails I can't find how to solve my issue ^^
I want to create a VideoPost from a form with a text field containing a video url (like youtube)
I'm getting information on the video thanks to the gem https://github.com/thibaudgg/video_info
And I want to save thoses information using a model of mine (VideoInformation).
But I don't know how the create process should work.
Thanks for any help !
I'm trying to create a VideoPost in VideoPostsController like this :
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
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
My VideoInformation model (which got same attributes name than 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