我使用發條寶石發送每日電子郵件。我在lib文件夾中創建了clock.rb文件。發條不適用於工頭
#clock.rb
require 'rubygems'
require 'clockwork'
include Clockwork
every(1.day, 'reminders.send', :at => '09:30'){
@leave_details = LeaveDetail.all(:conditions => {:status => [LeaveDetail::STATUS_PENDING, LeaveDetail::STATUS_PENDING_MNGT]})
@leave_details.each do |ld|
UserMailer.leave_reminder_email(ld).deliver
end
}
我已經創建了一個Procfile: -
web: bundle exec thin start -d
clock: bundle exec clockwork lib/clock.rb
當i命令
foreman start
它顯示錯誤: -
17:20:51 web.1 | started with pid 21144
17:20:51 clock.1 | started with pid 21146
17:20:52 clock.1 | I, [2012-12-06T17:20:52.558231 #21150] INFO -- : Starting clock for 1 events: [ reminder.deliver ]
17:20:52 clock.1 | I, [2012-12-06T17:20:52.558324 #21150] INFO -- : Triggering 'reminder.deliver'
17:20:52 clock.1 | E, [2012-12-06T17:20:52.558399 #21150] ERROR -- : uninitialized constant LeaveDetail (NameError)
17:20:52 clock.1 | /home/akhileshwar/Desktop/14-11-2012/RoR/P10HR/lib/clock.rb:8:in `block in <top (required)>'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:93:in `call'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:93:in `run'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:172:in `block in tick'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:170:in `each'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:170:in `tick'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:156:in `block in run'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:155:in `loop'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/lib/clockwork.rb:155:in `run'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/gems/clockwork-0.4.1/bin/clockwork:19:in `<top (required)>'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/bin/clockwork:23:in `load'
17:20:52 clock.1 | /home/akhileshwar/.rvm/gems/[email protected]/bin/clockwork:23:in `<main>'
17:20:52 web.1 | >> Deleting stale PID file tmp/pids/thin.pid
17:20:52 web.1 | exited with code 0
17:20:52 system | sending SIGTERM to all processes
SIGTERM received
17:20:52 clock.1 | terminated by SIGTERM
LeaveDetail是內部的紅寶石類楷模。 任何人都可以請告訴我爲什麼'LeaveDetail'在這裏顯示未初始化? thnks
你有沒有得到這個工作?我有類似的問題,瞭解發條如何與我的應用程序的其餘部分進行交互。 – MBHNYC