0

我正在关注使用 Rails 进行敏捷 Web 开发,第三版第 14 章。

我在windows中使用命令行输入这个命令: D:\InstantRails-2.0-win\rails_apps\GraduateDesign\depot>ruby -I test test/unit/product_test.rb

错误消息显示如下:

D:/InstantRails-2.0-win/rails_apps/GraduateDesign/depot/app/controllers/users_co
ntroller.rb:48: warning: don't put space before argument parentheses
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/acti
ve_support/dependencies.rb:445:in `load_missing_constant': uninitialized constan
t RUBY_COPYRIGHT (NameError)
        from D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2
.2.2/lib/active_support/dependencies.rb:77:in `const_missing'
        from D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2
.2.2/lib/active_support/dependencies.rb:89:in `const_missing'
        from D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rbx-require-rel
ative-0.0.9/lib/require_relative.rb:51
        from D:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom
_require.rb:36:in `gem_original_require'
        from D:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom
_require.rb:36:in `require'
        from D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2
.2.2/lib/active_support/dependencies.rb:155:in `require'
        from D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/linecache-0.45-
x86-mswin32/lib/linecache.rb:66
        from D:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom
_require.rb:31:in `gem_original_require'
         ... 16 levels...
        from D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2
.2.2/lib/active_support/dependencies.rb:155:in `require'
        from D:/InstantRails-2.0-win/rails_apps/GraduateDesign/depot/test/test_h
elper.rb:3
        from test/unit/product_test.rb:1:in `require'
        from test/unit/product_test.rb:1
4

2 回答 2

0

错误消息的重要部分是 rails 找不到RUBY_COPYRIGHT常量。自 1.8.7 以来,此常量是 ruby​​ 本身的一部分,因此我认为您使用的是较旧的东西。

鉴于此,您应该真正考虑一下

  1. 更新你的 Ruby。当前版本是 1.9.3
  2. 使用较新的 Rails。2.2.2 版严重过时。3.2.2 中的当前版本。

如果你的书/文档坚持使用这些旧版本,你应该找一本更好的书,尤其是在第一次学习 Rails 时。自 Ruby 1.8.6 和 Rails 2.2 以来,情况发生了重大变化。第四版 Agile Web Development with Rails 涵盖了 Rails 3。

于 2012-04-28T18:27:22.470 回答
0

我认为这不是导致错误的原因,但如果您忽略了它,您可能会检查它。

错误的第一行是这样的:

warning: don't put space before argument parenthesesusers_controller.rb 中的第 48 行。

于 2012-04-28T10:58:44.247 回答