我有一个带附加视频的模型。我想创建一个缩放版本的视频以及一系列缩略图。我有以下设置:
has_attached_file :video,
styles: {
original: { format: 'mp4', processors: [:transcoder] },
large: { geometry: "720x720", format: 'jpg', processors: [:thumbnail] },
medium: { geometry: "540x540", format: 'jpg', processors: [:thumbnail] },
thumb: { geometry: "180x180", format: 'jpg', processors: [:thumbnail] }
},
default_url: ""
当我在我的开发环境中测试它时,它运行得很好。视频和所有图像的大小正确。但是当我部署到Heroku时,我收到以下错误:
Validation failed: Video Paperclip::Errors::NotIdentifiedByImageMagickError
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/validations.rb:78:in `raise_validation_error'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/validations.rb:50:in `save!'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:324:in `block in save!'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:324:in `save!'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/suppressor.rb:45:in `save!'
/app/app/models/concerns/snapshot_methods.rb:37:in `copy_from_ziggeo!'
/app/app/workers/snapshot_transcoder.rb:16:in `perform'
/app/vendor/bundle/ruby/2.3.0/gems/resque-status-0.5.0/lib/resque/plugins/status.rb:161:in `safe_perform!'
/app/vendor/bundle/ruby/2.3.0/gems/resque-status-0.5.0/lib/resque/plugins/status.rb:137:in `perform'
我在这里缺少什么?我已经搜索了NotIdentifiedByImageMagickError
并在此问题上扫描了许多其他问题,但没有成功解决我的问题。
我见过的大多数解决方案都涉及在开发中设置Paperclip.options[:command_path] = "/usr/bin/identify"
。由于我的问题仅限于生产,我尝试将其应用于生产,在生产环境的正确路径上进行修改,如下所示:
Paperclip.options[:command_path] = "/app/vender/imagemagick/bin/identify"
这没有效果。也没有/app/vender/imagemagick/bin
。
答案 0 :(得分:0)
经过多次打击后,我设法通过清除我的应用程序缓存并重新安装ImageMagick来解决这个问题。以下是我采取的步骤:
heroku repo:purge_cache -a APP_NAME
。git commit --allow-empty -m "Hope this works"
git push heroku master
重新部署需要几分钟,因为Heroku现在必须从头开始重建所有静态资产和依赖项。
据我所知,这个问题是由ImageMagick的错误缓存副本引起的。我很高兴地接受任何能够为导致这个问题的原因提供更明智解释的人的答案。即使它现在已经解决了,我也不相信这不会在未来的某个随机点再次发生。