2013-07-12 71 views
-1

我升級了我的應用程序從紅寶石1.9.3到紅寶石2.0,保持我的大部分寶石沒有升級。 一切工作正常,但是當我嘗試上傳的圖像,我得到這個錯誤:Carrierwave/RMagick NoMethodError升級到紅寶石2.0後

NoMethodError - undefined method `[]=' for nil:NilClass: 
    app/uploaders/image_uploader.rb:91:in `block in optimize' 
    /home/stefpe/.rvm/gems/[email protected]/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/processing/rmagick.rb:263:in `manipulate!' 
    app/uploaders/image_uploader.rb:90:in `optimize' 
    /home/stefpe/.rvm/gems/[email protected]/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/processing.rb:85:in `block in process!' 
    /home/stefpe/.rvm/gems/[email protected]/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/processing.rb:81:in `each' 
    /home/stefpe/.rvm/gems/[email protected]/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/processing.rb:81:in `process!' 
    /home/stefpe/.rvm/gems/[email protected]/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks' 
    /home/stefpe/.rvm/gems/[email protected]/bundler/gems/carrierwave-5ee108128b40/lib/carrierwave/uploader/callbacks.rb:18:in `each' 
    /home/stefpe/.rvm/gems/[email protected]/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

carrierwave 0.6.2

rmagick 2.13.1

霧1.3.1

任何想法,爲什麼會出現與紅寶石2.0.0不兼容?

預先感謝您!

+0

你會很好,包括91行的摘錄,因爲錯誤味精說: –

回答

0

你應該嘗試更新一些寶石,carrierwave可能沒有在四月已與紅寶石2完全兼容2012

進一步激勵:Carrierwave didn't甚至傳遞選項加入到傳遞給manipulate!塊直到0.7

0

對我來說有效的是在操作結束時返回圖像! 在你的情況:

def optimize 
    manipulate! do |img, index, options| 
    options[:write] = { 
     :quality => 50, 
     :depth => 8, 
     :interlace => "Magick::PlaneInterlace" 
    } 
    img.strip! 
    img 
    end 
end