We have model Video

 # video.rb class Video < ActiveRecord::Base mount_uploader :file, FileUploader end 

How to create a Video object with a file via a rail console?

  • one
    Is there any gem for uploading? - MAXOPKA
  • yes, carrierwave - Alex I
  • one
    Try the option I wrote below. - MAXOPKA

1 answer 1

From the console, try this:

 Video.new(:file => File.new(path_to_video_file, "r")) 

path_to_video_file - the path to the video file

  • almost worked. flv file downloads everything to the uploads folder, but the file field in the Video model is for some reason file: ".flv" - Alex I