在我的Carrerwave自定义处理方法中,我正在尝试使用+repage
选项。文档很难找到,但我发现我需要运行img.repage.+
。然而,这并没有成功,因为它甚至没有尝试将选项转换为+,而是将其保持在-repage
并抛出错误说明同样多。然后我找到了一个说明的页面,将其写成:
img.push '+repage'
img.+
img.repage
它使用了一个不同的例子(不是使用repage,而是使用带有两个参数的'+ profile'。无论哪种方式它都不起作用......它现在告诉我undefined method 'gsub' for nil:NilClass
并指向{{1}行。
这是我的方法:
img.+
其他人对此有什么好运吗?
编辑 - 完整堆栈跟踪直到控制器以及更新的方法:
def custom_thumbnail
manipulate! do |img|
img.distort :srt, -30
img.repage.+
img.crop "#{model.crop_w}x#{model.crop_h}+#{model.crop_x}+#{model.crop_y}"
img
end
end
最终解决方案!
这显然是这样做的正确方法:
def custom_thumbnail
manipulate! do |img|
img.distort :srt, -30
img.push '+repage'
img.+
img.repage
img.crop "#{model.crop_w}x#{model.crop_h}+#{model.crop_x}+#{model.crop_y}"
img.resize "150x150"
img
end
end
mini_magick (3.6.0) lib/mini_magick.rb:486:in `+'
mini_magick (3.6.0) lib/mini_magick.rb:343:in `block in method_missing'
mini_magick (3.6.0) lib/mini_magick.rb:361:in `call'
mini_magick (3.6.0) lib/mini_magick.rb:361:in `combine_options'
mini_magick (3.6.0) lib/mini_magick.rb:342:in `method_missing'
app/uploaders/wine_photo_uploader.rb:67:in `block in custom_thumbnail'
carrierwave (0.9.0) lib/carrierwave/processing/mini_magick.rb:262:in `manipulate!'
app/uploaders/wine_photo_uploader.rb:64:in `custom_thumbnail'
carrierwave (0.9.0) lib/carrierwave/uploader/processing.rb:85:in `block in process!'
carrierwave (0.9.0) lib/carrierwave/uploader/processing.rb:81:in `each'
carrierwave (0.9.0) lib/carrierwave/uploader/processing.rb:81:in `process!'
carrierwave (0.9.0) lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks'
carrierwave (0.9.0) lib/carrierwave/uploader/callbacks.rb:18:in `each'
carrierwave (0.9.0) lib/carrierwave/uploader/callbacks.rb:18:in `with_callbacks'
carrierwave (0.9.0) lib/carrierwave/uploader/cache.rb:122:in `cache!'
carrierwave (0.9.0) lib/carrierwave/uploader/store.rb:56:in `store!'
activesupport (4.0.0) lib/active_support/core_ext/object/try.rb:45:in `public_send'
activesupport (4.0.0) lib/active_support/core_ext/object/try.rb:45:in `try'
carrierwave (0.9.0) lib/carrierwave/uploader/versions.rb:281:in `block in store_versions!'
carrierwave (0.9.0) lib/carrierwave/uploader/versions.rb:281:in `each'
carrierwave (0.9.0) lib/carrierwave/uploader/versions.rb:281:in `store_versions!'
app/uploaders/wine_photo_uploader.rb:101:in `block in recreate_versions!'
app/uploaders/wine_photo_uploader.rb:98:in `each'
app/uploaders/wine_photo_uploader.rb:98:in `recreate_versions!'
app/controllers/wines_controller.rb:78:in `update'
答案 0 :(得分:0)
阅读the source,我希望img.push '+repage'
或img.repage.+
能够正常运作。后者似乎是officially supported api。原始custom_thumbnail方法的跟踪是否相同?
另见: