如何解决“未初始化的常量 Clockwork (NameError)”

发布于 2024-11-26 02:19:30 字数 1581 浏览 0 评论 0原文

我成功安装了gem Clockwork

C:\web>gem install clockwork
Successfully installed clockwork-0.2.3
1 gem installed
Installing ri documentation for clockwork-0.2.3...
Installing RDoc documentation for clockwork-0.2.3...

但在运行简单脚本时

require 'rubygems'
require 'clockwork'
include Clockwork

every(1.minute, 'custom.event.handler' ) do
  puts "This event has its own handler - #{Time.new.strftime("%Y%m%d%H%M%S")}"
end

出现此错误

C:\web>ruby clockwork.rb
./clockwork.rb:3: uninitialized constant Clockwork (NameError)
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
        from clockwork.rb:2

任何建议如何使 Clockwork 在

  • Windows XP
  • ruby​​ 1.8.7 (2010-08-16 patchlevel 302) 上工作 ) [i386-mingw32]
  • gem 1.3.7

C:\web>gem list --local

*** LOCAL GEMS ***

aaronh-chronic (0.3.9)
activesupport (3.0.9)
backports (1.18.2)
clockwork (0.2.3)
daemons (1.1.0)
delayed_job (2.0.3)
eventmachine (0.12.10 x86-mswin32-60)
fastercsv (1.5.4)
haml (3.0.21)
i18n (0.6.0)
json (1.5.1)
mechanize (1.0.0)
monkey-lib (0.5.4)
nokogiri (1.5.0 x86-mingw32, 1.4.3.1 x86-mingw32)
rack (1.2.1)
rdiscount (1.6.8)
ruby-growl (3.0)
sinatra (1.2.6, 1.0)
sinatra-advanced-routes (0.5.1)
sinatra-reloader (0.5.0)
sinatra-sugar (0.5.1, 0.5.0)
thin (1.2.7 x86-mswin32)
tilt (1.3)

I successfully installed gem clockwork

C:\web>gem install clockwork
Successfully installed clockwork-0.2.3
1 gem installed
Installing ri documentation for clockwork-0.2.3...
Installing RDoc documentation for clockwork-0.2.3...

but when running simple script

require 'rubygems'
require 'clockwork'
include Clockwork

every(1.minute, 'custom.event.handler' ) do
  puts "This event has its own handler - #{Time.new.strftime("%Y%m%d%H%M%S")}"
end

I get this error

C:\web>ruby clockwork.rb
./clockwork.rb:3: uninitialized constant Clockwork (NameError)
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
        from clockwork.rb:2

Any suggestion how to make clockwork work on

  • Windows XP
  • ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
  • gem 1.3.7

C:\web>gem list --local

*** LOCAL GEMS ***

aaronh-chronic (0.3.9)
activesupport (3.0.9)
backports (1.18.2)
clockwork (0.2.3)
daemons (1.1.0)
delayed_job (2.0.3)
eventmachine (0.12.10 x86-mswin32-60)
fastercsv (1.5.4)
haml (3.0.21)
i18n (0.6.0)
json (1.5.1)
mechanize (1.0.0)
monkey-lib (0.5.4)
nokogiri (1.5.0 x86-mingw32, 1.4.3.1 x86-mingw32)
rack (1.2.1)
rdiscount (1.6.8)
ruby-growl (3.0)
sinatra (1.2.6, 1.0)
sinatra-advanced-routes (0.5.1)
sinatra-reloader (0.5.0)
sinatra-sugar (0.5.1, 0.5.0)
thin (1.2.7 x86-mswin32)
tilt (1.3)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

左岸枫 2024-12-03 02:19:30

让我给你一个提示。您自己的程序的名称是clockwork.rb,您可以在其中执行以下操作:

require 'clockwork'

看到问题了吗?

Let me give you a hint. The name of your own program is clockwork.rb, and in it you do:

require 'clockwork'

See the problem?

黑寡妇 2024-12-03 02:19:30

您需要在clock.rb中包含以下内容

require './config/boot'
需要 './coonfig/environment'

you need to include the following in your clock.rb

require './config/boot'
require './coonfig/environment'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文