0

I am developing a blog using Ruby on Rails and I wanted to use the carrierwave gem to upload videos. I have used this helpful post to follow: Upload Video in a rails application

I have already tried Rails Carrierwave Video Uploader by adding and this does not seem make a difference.

video_uploader.rb:

   class VideoUploader < CarrierWave::Uploader::Base
   storage :file

   def store_dir
   "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
   end
   end

new.html.erb:

<%= f.label :video %><br>
    <%= f.file_field :video %>

show.html.erb:

    <% @posts.each do |post|%>
    <%= video_tag post.video_url.to_s :controls =>true %>
    <% end %>

When I create the new post, I am unable to click "show" because of the following error

  Showing C:/Sites/Application/app/views/posts/show.html.erb where line #10 raised:

  undefined method `each' for nil:NilClass 


    Line 10 :<% @posts.each do |posts|%>
    Line 11: <%= video_tag post.video_url.to_s :controls =>true %>
    Line 12: <% end %>

I have saved the videos in assets/videos. Once they get uploaded through the application, they are being saved in public/uploads/posts/video/1/vid1.mp4

Yogi
  • 19
  • 4

0 Answers0