我试图让上传电影文件成为可能。为此,我安装了Paperclip gem。我的电影课看起来像这样:
class Movie < ActiveRecord::Base
belongs_to :user
has_attached_file :movie_file,
styles: lambda { |a| a.instance.is_image? ? {:small => "x200>", :medium => "x300>", :large => "x400>"} : {:thumb => { :geometry => "100x100#", :format => 'mkv', :time => 10}, :medium => { :geometry => "300x300#", :format => 'mkv', :time => 10}}},
processors: lambda { |a| a.is_video? ? [ :ffmpeg ] : [ :thumbnail ] }
validates_attachment :movie_file, presence: true,
content_type: { content_type: "movie/mkv" }
然而,每次上传尝试都会出现has contents that are not what they are reported to be
错误。我怎么能绕过那个?
更新:
完整错误是&#39;验证失败:电影文件的内容不是报告的内容,电影文件无效,电影文件内容类型无效&#39;
Stacktrace只会导致save!
方法:
app/controllers/movies_controller.rb:21:in `block in create'
app/controllers/movies_controller.rb:20:in `create'