简体   繁体   English

将我的应用程序升级到rails 3.1.1时获取NameError

[英]Getting a NameError when upgrading my app to rails 3.1.1

The name of my app is newsample_app . 我的应用名称是newsample_app。 I am following along the railstutorial screencast for upgrading to rails 3.1. 我正在关注railsstutorial截屏,以升级到rails 3.1。 Here is the error message I am getting when copying files over from my old "sample_app" to "newsample_app" and trying to run rspec: 以下是将文件从旧的“sample_app”复制到“newsample_app”并尝试运行rspec时出现的错误消息:

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

After seeing this, I changed my routes.rb file from my original sample_app from "SampleApp::Application.routes.draw do" to this: "NewSampleApp::Application.routes.draw do" but am still getting the error. 看到这个之后,我将来自原始sample_app的routes.rb文件从“SampleApp :: Application.routes.draw do”更改为:“NewSampleApp :: Application.routes.draw do”但仍然出现错误。 Any ideas? 有任何想法吗?

FYI complete error: 仅供参考完整错误:

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/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `block in load_paths'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `each'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `load_paths'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:13:in `reload!'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:7:in `block in initialize'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `call'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/finisher.rb:63:in `block (2 levels) in <module:Finisher>'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/finisher.rb:64:in `call'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application/finisher.rb:64:in `block in <module:Finisher>'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_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/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
    from /Users/topica/.rvm/gems/ruby-1.9.2-p290@rails3_1tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'

Looks like a case problem. 看起来像一个案例问题。

> "newsample_app".camelize
 => "NewsampleApp" 

Note the lowercase "s". 注意小写的“s”。

您可能希望它与config / application.rb中的匹配相同如果它确实是newsample_app而不是它可能是NewsampleApp而不是NewSampleApp

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取 NameError:升级到 Rails 7 的未初始化常量错误 - Getting a NameError: uninitialized constant error upgrading to Rails 7 Bootstrap 3.1.1 Javascript无法在我的Rails应用程序中运行 - Bootstrap 3.1.1 Javascript not working in my rails app 升级到 Rails 6 时,是否有一种编程方式来检测 Zeitwerk::NameError? - There is a programmatical way to detect Zeitwerk::NameError when upgrading to Rails 6? NameError:升级到rails3时未初始化的常量Test :: Unit :: AssertionFailedError - NameError: uninitialized constant Test::Unit::AssertionFailedError when upgrading to rails3 运行Rails服务器时出现NameError - NameError when I run my rails server 升级到Rails 3.1.1之后:“未定义的方法&#39;javascript_expansions&#39;”错误 - After upgrading to Rails 3.1.1: “undefined method `javascript_expansions'” error 升级到Rails 4.2.3时,出现“ NameError:未初始化的常量ActionController :: Responder” - When upgrading to Rails 4.2.3 I get “NameError: uninitialized constant ActionController::Responder” 运行命令Rails服务器时出现NameError - Getting a NameError when I run the command rails server NameError:尝试导入CSV时在Rails应用程序中未初始化的常量 - NameError: uninitialized constant in Rails app when attempting to import CSV NameError:使用RSpec和Spork进行测试时Rails应用程序中的未初始化常量 - NameError: uninitialized constant in Rails app when testing with RSpec and Spork
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM