查看文檔'Example clock.rb
file'here,您可以看到我的代碼完全遵循發條約定(?)。但是,我收到這個錯誤,我似乎無法修復。我嘗試了多元化和單變化的不同變量。NameError using Rails,Sidekiq&Clockwork
`<module:Clockwork>': uninitialized constant Clockwork::Event::Manager (NameError)
from /Users/MightyMouse/Desktop/DevBootcamp/phase-3/medmento/config/clock.rb:7:in `<top (required)>'
from /Users/MightyMouse/.rvm/gems/ruby-2.0.0-p598/gems/clockwork-1.1.0/bin/clockwork:12:in `require'
from /Users/MightyMouse/.rvm/gems/ruby-2.0.0-p598/gems/clockwork-1.1.0/bin/clockwork:12:in `<top (required)>'
from /Users/MightyMouse/.rvm/gems/ruby-2.0.0-p598/bin/clockwork:23:in `load'
from /Users/MightyMouse/.rvm/gems/ruby-2.0.0-p598/bin/clockwork:23:in `<main>'
from /Users/MightyMouse/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `eval'
from /Users/MightyMouse/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `<main>'
這是我clock.rb
文件:
require_relative "../config/boot"
require_relative "../config/environment"
require 'clockwork'
require 'clockwork/database_events'
module Clockwork
Clockwork.manager = Event::Manager.new
sync_database_events model: ClockworkEvent, every: 1.minute do |model_instance|
TwilioWorker.perform_async
end
end
從本質上講,我希望發條會(1)通過每個model_instance
就像上面循環,(2)找到和frequency_period
(通過數據庫關聯組成「時間」),以及(3)在「時間」的右側調用TwilioWorker
。
我試過用下面的代碼替換塊。當我運行clock.rb
,我能夠從Twilio接到一個電話:
every(1.minutes, "twilio_call.job") { TwilioWorker.perform_async }