2012-11-16 38 views
1

ImageWorker在我Banner模式,我稱此:未初始化的恆定,同時調用sidekiq

after_save :enqueue_image 

    def enqueue_image 
    ImageWorker.perform_async(id, key) if key.present? 
    end 

class ImageWorker 
    include Sidekiq::Worker 

    def perform(id, key) 
    banner = Banner.find(id) 
    banner.key = key 
    banner.remote_image_url = banner.image.direct_fog_url(with_path: true) 
    banner.save! 
    end 
end 

我在sidekiq得到的錯誤是這樣的:

2012-11-16T12:30:35Z 75701 TID-ows7fyu3w WARN: {"retry"=>true, "queue"=>"default", "class"=>"Banner::ImageWorker", "args"=>[6, "uploads/af-64b9e8b8c96a/770x350.gif"], "jid"=>"b8f23a2387f2b751"} 
2012-11-16T12:30:35Z 75701 TID-ows7fyu3w WARN: uninitialized constant Banner::ImageWorker 
2012-11-16T12:30:35Z 75701 TID-ows7fyu3w WARN: /.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize' 
/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each' 
/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize' 
/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize' 
/.rvm/gems/[email protected]/gems/sidekiq-2.5.3/lib/sidekiq/processor.rb:37:in `block in process' 
/.rvm/gems/[email protected]/gems/celluloid-0.12.3/lib/celluloid/calls.rb:57:in `call' 
/.rvm/gems/[email protected]/gems/celluloid-0.12.3/lib/celluloid/calls.rb:57:in `dispatch' 
/.rvm/gems/[email protected]/gems/celluloid-0.12.3/lib/celluloid/future.rb:18:in `block in initialize' 
/.rvm/gems/[email protected]/gems/celluloid-0.12.3/lib/celluloid/internal_pool.rb:48:in `call' 
/.rvm/gems/[email protected]/gems/celluloid-0.12.3/lib/celluloid/internal_pool.rb:48:in `block in create' 
+0

需要'橫幅'並檢查 – Amar

+0

這是在Rails 3應用程序中。所以不需要 - 據我所知。 – marcamillion

+0

您的橫幅廣告模型是否有可能在模塊內命名空間?如果是這樣,您需要在ImageWorker前加上':: ImageWorker',以便知道該模塊在該模塊之外。 –

回答

0

我有這個問題時,幾個sidekiq進程正在運行。

0

我知道這是一個老問題,但偶然發現,因爲我有類似的問題。

擺弄我發現這issue on github這讓我明白,我做錯了,並讓我的工人在lib文件夾。

將它移動到worker文件夾解決了問題。