代码之家  ›  专栏  ›  技术社区  ›  Trip

加载时缺少常量。。我怎么能避开这个?

  •  1
  • Trip  · 技术社区  · 13 年前

    我刚刚安装了一个rails 2.3.5项目的bundler。

    这样做之后,我意识到当我去 script/console :

    Loading development environment (Rails 2.3.5)
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `const_missing':NameError: uninitialized constant Rails::Plugin::OpenID
    

    我的Gemfile:

    gem 'ruby-openid', '2.1.8'
    

    我跑了 bundle install 没有错误。

    >>gem列表-d ruby openid

    *** LOCAL GEMS ***
    
    ruby-openid (2.1.8, 2.1.2)
    Author: JanRain, Inc
    Homepage: http://github.com/openid/ruby-openid
    Installed at (2.1.8): /Library/Ruby/Gems/1.8
                 (2.1.2): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
    

    完全回溯

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant Rails::Plugin::OpenID (NameError)
        from /Users/macuser/Sites/test/spree/vendor/plugins/open_id_authentication/init.rb:16:in `evaluate_init_rb'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in `call'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in `evaluate_method'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `each'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `send'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:51:in `send'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:51:in `run_prepare_callbacks'
        from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:631:in `prepare_dispatcher'
        from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:185:in `process'
        from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
        from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
        from ./script/../config/../lib/spree/initializer.rb:90:in `run'
        from /Users/macuser/Sites/test/spree/config/environment.rb:26
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
        from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
        from script/server:3:in `require'
        from script/server:3
    

    关于现在检查什么有什么线索吗?谢谢你!

    1 回复  |  直到 13 年前
        1
  •  1
  •   Cory    13 年前

    我以前也提到过这一点-我认为这可能与Gemfile中的require语法有关。。。

    我刚把一个Gemfile放在一起扔进去。。。

    gem "ruby-openid", :require => 'openid'
    

    能够在公认的缩小测试环境中启动控制台。。。