查看文档中的“示例clock.rb
文件” ,您可以看到我的代码完全遵循发条约定(?)。但是,我收到了这个似乎无法修复的错误。我尝试过对不同的变量进行复数和单数化。
`<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
本质上,我希望 Clockwork 将(1)循环遍历每个model_instance
如上所示,(2)通过数据库关联找到frequency_quantity
and frequency_period
(它们一起构成“时间”),以及(3)调用TwilioWorker
右侧的“时间”。
我试过用下面的代码替换块。当我运行时clock.rb
,我可以接到来自 Twilio 的电话:
every(1.minutes, "twilio_call.job") { TwilioWorker.perform_async }