当我运行我的时钟装置时,我得到这个错误:
C:\Rails\konkurranceportalen>bundle exec clockwork lib/clock.rb
Starting clock for 1 events: [ statistik ]
Triggering statistik
Exception NameError -> uninitialized constant Delayed::Job
lib/clock.rb:6:in `block in <top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:27:in `c
all'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:27:in `r
un'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:96:in `b
lock in tick'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:94:in `e
ach'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:94:in `t
ick'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:80:in `b
lock in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:79:in `l
oop'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:79:in `r
un'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/bin/clockwork:20:in `<top
(required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/bin/clockwork:19:in `load'
C:/Ruby192/lib/ruby/gems/1.9.1/bin/clockwork:19:in `<main>'我在lib文件夹中的clock.rb:
require 'rubygems'
require 'clockwork'
include Clockwork
every(2.minutes, 'statistik') { Delayed::Job.enqueue(Scraper.new) }我已将我的clock.rb更改为:
require 'clockwork'
require 'delayed_job'
include Clockwork
every(2.minutes, 'statistik') { Delayed::Job.enqueue(Scraper.new) 然后我得到了这个错误:
C:\Rails\konkurranceportalen>bundle exec clockwork lib/clock.rb
Starting clock for 1 events: [ statistik ]
Triggering statistik
Exception NameError -> uninitialized constant Delayed::Job
lib/clock.rb:5:in `block in <top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:27:in `c
all'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:27:in `r
un'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:96:in `b
lock in tick'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:94:in `e
ach'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:94:in `t
ick'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:80:in `b
lock in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:79:in `l
oop'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/lib/clockwork.rb:79:in `r
un'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/clockwork-0.2.3/bin/clockwork:20:in `<top
(required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/bin/clockwork:19:in `load'
C:/Ruby192/lib/ruby/gems/1.9.1/bin/clockwork:19:in `<main>'我在lib文件夹中的scraper.rb:
class Scraper
require 'mechanize'
def iqmedier
#SOME CODE
end
def mikkelsen
#SOME CODE
end
def orville
#SOME CODE
end
end发布于 2011-04-22 19:11:16
我实际上并不熟悉ClockWork,但是您不需要在clock.rb的顶部添加一个"require 'delayed_job'“吗?您可能还需要安装delayed_job gem。
也就是说,如果你运行的是“bundle exec”,你应该使用一个Gemfile来管理它,并且你不应该在clock.rb中需要rubygem。
https://stackoverflow.com/questions/5754722
复制相似问题