resqueワーカー内に含まれているモジュールからメソッドを呼び出すのに問題があります。say
以下の例では、ワーカー内(TestLibモジュール内)でメソッドを呼び出そうとすると、未定義のメソッドエラーが発生し続けます。問題を説明するために、コードを基本的なものに減らしました。
コントローラー (/app/controllers/test_controller.rb)
class TestController < ApplicationController
def testque
Resque.enqueue( TestWorker, "HI" )
end
end
ライブラリ (/lib/test_lib.rb)
module TestLib
def say( word )
puts word
end
end
ワーカー (/workers/test_worker.rb)
require 'test_lib'
class TestWorker
include TestLib
@queue = :test_queue
def self.perform( word )
say( word ) #returns: undefined method 'say' for TestWorker:Class
TestLib::say( word ) #returns: undefined method 'say' for TestLib::Module
end
end
Rakefile (resque.rake)
require "resque/tasks"
task "resque:setup" => :environment
次のコマンドを使用してresqueを実行しています。rake environment resque:work QUEUE='*'
Gems:rails(3.0.4)redis(2.2.2)redis-namespace(1.0.3)resque(1.19.0)
サーバー:nginx / 1.0.6
誰かがそこで何が起こっているのかについて何か考えがありますか?