リクルートワーカー内のインクルードされたモジュールからメソッドを呼び出す際に問題があります。以下の例では、私はsay
メソッドを(TestLibモジュールにある)ワーカー内部で呼び出そうとすると、定義されていないメソッドエラーを取得し続けます。Rails外部モジュールで未定義メソッドエラーを再現する
コントローラ (/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
ワーカー (/労働/ test_worke r.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='*'
宝石: レール(3.0.4を) redis(2.2.2) redis-namespace(1.0.3) resque(1.19.0)
サーバー: nginxの/ 1.0.6
誰もがそこに何が起こっているのかについてどのような考えを持っていますか?
* headslap *私は最近、あまりレールで作業していると思います。それがトリックでした。ありがとう! – internetoutfitters
+1 @tbuehlmann。 –
これを行っても問題が解決しない場合は、サーバーを再起動してください – Kathan