Reputation: 97
I wanted to let users upload a video, so I used carrierwave to add that functionality. When I run it, I get the following error
My userinfo index code:
<h1>YOUR PROFILE IS HERE</h1>
<% @userinfors.each do |post|%>
<%= video_tag post.video_url.to_s :controls =>true %>
<%end%>
My userinfo controller:
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
My userinfo model:
class Userinfo < ActiveRecord::Base
belongs_to :user
mount_uploader :video, VideoUploader
end
The video_uploader file created for carrierwave:
class VideoUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
My migration file to add videos to userinfo model:
class AddVideoToUserinfo < ActiveRecord::Migration
def change
add_column :userinfos, :video, :string
end
end
Any help is appreciated. Thanks
Upvotes: 0
Views: 33
Reputation: 2656
You are missing a comma:
video_tag(post.video_url.to_s, :controls => true)
Upvotes: 1