2011-10-19 114 views
0

我的應用程序的名稱是newsample_app。我沿着railstutorial截屏直播來升級到rails 3.1。這是從我的舊「sample_app」到「newsample_app」複製文件時過,並試圖rspec的運行我收到錯誤消息:將應用程序升級到rails時出現NameError錯誤3.1.1

rspec spec/controllers/pages_controller_spec.rb /Users/topica/rails_projects/newsample_app/config/routes.rb:1:in `': uninitialized constant NewSampleApp (NameError)

見狀後,我從原來的sample_app改變了我的routes.rb文件從「SampleApp :: Application.routes.draw做」到這個:「NewSampleApp :: Application.routes.draw做」但我仍然得到錯誤。有任何想法嗎?

FYI完整的錯誤:

Topicas-MacBook-Pro:newsample_app topica$ rspec spec/controllers/pages_controller_spec.rb 
/Users/topica/rails_projects/newsample_app/config/routes.rb:1:in `<top (required)>': uninitialized constant NewSampleApp (NameError) 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `block in load_paths' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `each' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `load_paths' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:13:in `reload!' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:7:in `block in initialize' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `call' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `execute_if_updated' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/finisher.rb:63:in `block (2 levels) in <module:Finisher>' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/finisher.rb:64:in `call' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application/finisher.rb:64:in `block in <module:Finisher>' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing' 
    from /Users/topica/rails_projects/newsample_app/config/environment.rb:5:in `<top (required)>' 
    from /Users/topica/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/topica/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/topica/rails_projects/newsample_app/spec/spec_helper.rb:3:in `<top (required)>' 
    from /Users/topica/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/topica/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/topica/rails_projects/newsample_app/spec/controllers/pages_controller_spec.rb:1:in `<top (required)>' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run' 
    from /Users/topica/.rvm/gems/[email protected]_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun' 

回答

1

你可能希望這樣的匹配相同的config/application.rb中 如果真的是newsample_app比它可能是NewsampleApp不NewSampleApp

+0

衛生署! jdl打我吧 – house9

+0

哦,夥計。兩者都正確。下次我會直接去irb for .camelize。感謝您的幫助,不會再犯這個錯誤:) – kcurtin

+0

@ house9我覺得這很接近。我爲此付出了+1的努力。 – jdl

1

看起來像一個情況下的問題。

> "newsample_app".camelize 
=> "NewsampleApp" 

請注意小寫字母「s」。

相關問題