Yeniden boyutlandırma çalışanı içinde dahil edilen bir modülden yöntemleri çağırmakta zorlanıyorum. Aşağıdaki örnekte, işçide (TestLib modülünde bulunan) say
yöntemini çağırmaya çalıştığımda tanımlanmamış bir yöntem hatası alıyorum. Sorunu göstermek için çıplak temelleri aşağı kodunu düşürdük:Raylar Harici modülde tanımlanmamış yöntem hatası
Kontrolör (/app/controllers/test_controller.rb)
class TestController < ApplicationController
def testque
Resque.enqueue(TestWorker, "HI")
end
end
Kütüphane (/ lib/test_lib. rb)
module TestLib
def say(word)
puts word
end
end
işçi (/ işçi/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
aşağıdaki komutu kullanarak resque çalıştırıyorum: rake environment resque:work QUEUE='*'
Taşlar: raylar (3.0.4) redis (2.2.2) redis-isim alanı (1.0.3) resque (1.19.0)
Sunucusu: orada nginx/1.0.6
Herkes herhangi bir fikir var oluyor ne olduğu?
* headslap * Son zamanlarda raylarda çok çalışıyorum galiba. Bu hile yaptı. Teşekkürler! – internetoutfitters
+1 @tbuehlmann. –
Bunu yaparsanız ve hala çalışmıyorsa, sunucunuzu yeniden başlatın. – Kathan