首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails help clockwork错误: Exception NameError -> uninitialized constant Delayed::Job

Rails help clockwork错误: Exception NameError -> uninitialized constant Delayed::Job
EN

Stack Overflow用户
提问于 2011-04-22 18:57:17
回答 1查看 1.5K关注 0票数 2

当我运行我的时钟装置时,我得到这个错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
require 'rubygems'
require 'clockwork'
include Clockwork

every(2.minutes, 'statistik') { Delayed::Job.enqueue(Scraper.new) }

我已将我的clock.rb更改为:

代码语言:javascript
复制
require 'clockwork'
require 'delayed_job'
include Clockwork

every(2.minutes, 'statistik') { Delayed::Job.enqueue(Scraper.new) 

然后我得到了这个错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
class Scraper
require 'mechanize'
def iqmedier
    #SOME CODE

  end

def mikkelsen
#SOME CODE

   end
def orville
   #SOME CODE
   end
end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-04-22 19:11:16

我实际上并不熟悉ClockWork,但是您不需要在clock.rb的顶部添加一个"require 'delayed_job'“吗?您可能还需要安装delayed_job gem。

也就是说,如果你运行的是“bundle exec”,你应该使用一个Gemfile来管理它,并且你不应该在clock.rb中需要rubygem。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5754722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档