【问题标题】:How to solve " uninitialized constant Clockwork (NameError)"如何解决“未初始化的常量发条(NameError)”
【发布时间】:2013-11-24 02:18:04
【问题描述】:

我成功安装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

关于如何使发条正常工作的任何建议

  • Windows XP
  • ruby 1.8.7(2010-08-16 补丁级别 302)[i386-mingw32]
  • 宝石 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)

【问题讨论】:

    标签: ruby rubygems scheduling


    【解决方案1】:

    让我给你一个提示。你自己的程序的名字是clockwork.rb,在里面你做:

    require 'clockwork'
    

    看到问题了吗?

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2011-12-13
        • 1970-01-01
        • 2015-01-19
        • 2015-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-04
        • 2016-06-12
        相关资源
        最近更新 更多