Rails载波视频上传器 [英] Rails Carrierwave Video Uploader

查看:54
本文介绍了Rails载波视频上传器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Rails 4应用程序中使用了carrierwave。

Im using carrierwave with my Rails 4 app.

我安装了两个上传器-一个用于头像,一个用于视频。我在项目模型中都使用了它们。我的project.rb文件具有:

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

我的项目控制者包括:

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

我的项目_form具有:

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 %>

我已尝试遵循本文第7步答案中的示例在Rails应用程序中上传视频(但将视频标签从post.video更改为@ project.link_to_video_proposal

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?

谢谢

推荐答案

我已经解决了添加micropost.video是否存在的问题?。

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

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

这篇关于Rails载波视频上传器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆