我将我的应用程序从 ruby 1.9.3 升级到 ruby 2.0,让我的大部分 gem 没有升级。一切正常,但是当我尝试上传图片时,出现此错误:
NoMethodError - undefined method `[]=' for nil:NilClass:
app/uploaders/image_uploader.rb:91:in `block in optimize'
/home/stefpe/.rvm/gems/ruby-2.0.0-p195@Lefkada/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/processing/rmagick.rb:263:in `manipulate!'
app/uploaders/image_uploader.rb:90:in `optimize'
/home/stefpe/.rvm/gems/ruby-2.0.0-p195@Lefkada/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/processing.rb:85:in `block in process!'
/home/stefpe/.rvm/gems/ruby-2.0.0-p195@Lefkada/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/processing.rb:81:in `each'
/home/stefpe/.rvm/gems/ruby-2.0.0-p195@Lefkada/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/processing.rb:81:in `process!'
/home/stefpe/.rvm/gems/ruby-2.0.0-p195@Lefkada/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks'
/home/stefpe/.rvm/gems/ruby-2.0.0-p195@Lefkada/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/callbacks.rb:18:in `each'
/home/stefpe/.rvm/gems/ruby-2.0.0-p195@Lefkada/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/callbacks.rb:18:in `with_callbacks'
image_uploader.rb 基于 /carrierwave/processing/rmagick.rb 示例 manipulate
函数:
def optimize
manipulate! do |img, index, options|
options[:write] = {
:quality => 50,
:depth => 8,
:interlace => "Magick::PlaneInterlace"
}
img.strip!
end
end
配置:服务器:heroku,本地开发:linux
红宝石 1.9.3 -> 2.0
导轨 3.2.13
载波 0.6.2
rmagick 2.13.1
雾 1.3.1
知道为什么与 ruby-2.0.0 不兼容吗?
先感谢您!