尝试在 rails 应用程序上显示视频时出现参数错误
Getting argumenterror when trying to display video on rails app
我想让用户上传视频,所以我使用 carrierwave 来添加该功能。当我 运行 它时,我得到以下错误
我的用户信息索引代码:
<h1>YOUR PROFILE IS HERE</h1>
<% @userinfors.each do |post|%>
<%= video_tag post.video_url.to_s :controls =>true %>
<%end%>
我的用户信息控制器:
class UserinfosController < ApplicationController
def index
@userinfors = Userinfo.all
end
def show
end
def new
@userinformation = Userinfo.new
end
def create
@userinformation = Userinfo.new(userinfo_params)
if @userinformation.save
redirect_to root_path
else
render 'new'
end
end
def edit
end
def update
end
def destroy
end
private
def userinfo_params
params.require(:userinfo).permit(:name, :email, :college, :gpa, :major, :video)
end
end
我的用户信息模型:
class Userinfo < ActiveRecord::Base
belongs_to :user
mount_uploader :video, VideoUploader
end
为载波创建的video_uploader文件:
class VideoUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
我将视频添加到 userinfo 模型的迁移文件:
class AddVideoToUserinfo < ActiveRecord::Migration
def change
add_column :userinfos, :video, :string
end
end
感谢任何帮助。谢谢
您缺少一个逗号:
video_tag(post.video_url.to_s, :controls => true)
我想让用户上传视频,所以我使用 carrierwave 来添加该功能。当我 运行 它时,我得到以下错误
我的用户信息索引代码:
<h1>YOUR PROFILE IS HERE</h1>
<% @userinfors.each do |post|%>
<%= video_tag post.video_url.to_s :controls =>true %>
<%end%>
我的用户信息控制器:
class UserinfosController < ApplicationController
def index
@userinfors = Userinfo.all
end
def show
end
def new
@userinformation = Userinfo.new
end
def create
@userinformation = Userinfo.new(userinfo_params)
if @userinformation.save
redirect_to root_path
else
render 'new'
end
end
def edit
end
def update
end
def destroy
end
private
def userinfo_params
params.require(:userinfo).permit(:name, :email, :college, :gpa, :major, :video)
end
end
我的用户信息模型:
class Userinfo < ActiveRecord::Base
belongs_to :user
mount_uploader :video, VideoUploader
end
为载波创建的video_uploader文件:
class VideoUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
我将视频添加到 userinfo 模型的迁移文件:
class AddVideoToUserinfo < ActiveRecord::Migration
def change
add_column :userinfos, :video, :string
end
end
感谢任何帮助。谢谢
您缺少一个逗号:
video_tag(post.video_url.to_s, :controls => true)