Ho problemi a chiamare i metodi da un modulo incluso all'interno di un operatore resque. Nell'esempio seguente, continuo a ricevere errori di metodo non definiti quando tento di chiamare il metodo say
all'interno dell'operatore (che si trova nel modulo TestLib). Ho ridotto il codice giù ai principi fondamentali nude per illustrare il problema:Rails Resque errore metodo non definito nel modulo esterno
controller (/app/controllers/test_controller.rb)
class TestController < ApplicationController
def testque
Resque.enqueue(TestWorker, "HI")
end
end
Biblioteca (/ lib/test_lib. rb)
module TestLib
def say(word)
puts word
end
end
Worker (/ lavoratori/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
sto correndo resque utilizzando il seguente comando: rake environment resque:work QUEUE='*'
gemme: rotaie (3.0.4) redis (2.2.2) redis-namespace (1.0.3) resque (1.19.0)
Server: nginx/1.0.6
Qualcuno ha qualche idea su cosa sta succedendo lì?
* head cap * Credo di aver lavorato troppo su rotaie ultimamente. Questo ha fatto il trucco. Grazie! – internetoutfitters
+1 @tbuehlmann. –
Se si esegue questa operazione e continua a non funzionare, riavviare il server – Kathan