resque 작업자 내부의 포함 된 모듈에서 메서드를 호출하는 데 문제가 있습니다. 아래의 예제에서, worker (TestLib 모듈에 있음) 내부에서 say
메서드를 호출하려고 시도 할 때 정의되지 않은 메서드 오류가 계속 발생합니다. 나는이 문제를 설명하기 위해 베어 기본으로 아래 코드를 감소했습니다레일 외부 모듈에서 정의되지 않은 메서드 오류를 다시 수정하십시오.
컨트롤러 (/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