Dinukaperera
Dinukaperera

Reputation: 97

Getting argumenterror when trying to display video on rails app

I wanted to let users upload a video, so I used carrierwave to add that functionality. When I run it, I get the following errorenter image description here

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

Answers (1)

Bart
Bart

Reputation: 2656

You are missing a comma:

video_tag(post.video_url.to_s, :controls => true)

Upvotes: 1

Related Questions