Rails Carrierwave Video Uploader

2019-08-27 04:35发布

问题:

Im using carrierwave with my Rails 4 app.

I have two uploaders installed - one for avatar and one for video. I use both of them in my projects model. My project.rb file has:

mount_uploader :hero_image, AvatarUploader
  mount_uploader :link_to_video_proposal, VideoUploader

My project controller includes:

params.require(:project).permit(:link_to_video_proposal)

My project _form has:

  <%=f.file_field :link_to_video_proposal%>

My project show page has:

     <%= video_tag @project.link_to_video_proposal_url.to_s :controls =>true %>

I have tried to follow the example in the 7 step answer in this post Upload Video in a rails application (but changed the video tag from post.video to @project.link_to_video_proposal

When I save this and test it, I get an error that says:

wrong number of arguments (1 for 0) (referring to the line in my show page).

Can anyone see what I have done wrong?

Thank you

回答1:

I've solved the problem with adding if micropost.video?..

<%= video_tag micropost.video_url.to_s :controls =>true if micropost.video?%>