未初始化的常量ActionController

时间:2013-04-27 16:56:34

标签: ruby-on-rails actioncontroller nameerror

背景故事:有些朋友和我正在开发一款应用,想要在另一个页面上选择多个项目进行处理。在我们找到RailsCast #165之前,我创建了一个分支并为表添加了一个脚手架,上面有三个复选框,只是为了查看生成的代码是什么样的。在RC165中找到了正确答案后,我删除了所有代码和迁移,意图放弃所有工作。

唉,我似乎无法摆脱它,因为对它的引用阻止我在任何分支上做任何事情。当我“rake db:migrate”或“rails s”或任何东西时,我得到......

uninitialized constant ActionController::MimeResponds::ChecksHelper (NameError)

...即使字符串“Checks”确实出现在我的项目目录中。我到目前为止:

  1. 重命名目录并从github克隆一个新项目(注意:我的实验从未 甚至在本地文件系统级别提交,更不用说了。)
  2. 打破Postgress开发和测试数据库
  3. 我完全不知道Rails是如何以及在哪里“记住”我的简短实验,并且没有想法吹掉Ruby,Rails和rbenv,即将机器刮到基岩上 - 哎呀。 >

    我简直不敢相信只是从一些考虑不周的代码中退出就应该这么难。

    关于如何解决这个问题或将来避免使用它的任何建议都会受到欢迎。

    - Vern

    堆栈跟踪如下:

    Verns-MacBook-Pro:Portfolio-Project-1-User-Stories vern$ git branch
    * master
    Verns-MacBook-Pro:Portfolio-Project-1-User-Stories vern$ rails s
    => Booting WEBrick
    => Rails 3.2.11 application starting in development on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    Exiting
    /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/mime_responds.rb:11:in `<module:MimeResponds>': uninitialized constant ActionController::MimeResponds::ChecksHelper (NameError)
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/mime_responds.rb:6:in `<module:ActionController>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/mime_responds.rb:5:in `<top (required)>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_controller/base.rb:196:in `<class:Base>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_controller/base.rb:171:in `<module:ActionController>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_controller/base.rb:3:in `<top (required)>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sorcery-0.8.1/lib/sorcery/engine.rb:11:in `block in <class:Engine>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /Users/vern/RoR/Portfolio-Project-1-User-Stories/config/environment.rb:5:in `<top (required)>'
        from /Users/vern/RoR/Portfolio-Project-1-User-Stories/config.ru:3:in `block in <main>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
        from /Users/vern/RoR/Portfolio-Project-1-User-Stories/config.ru:in `new'
        from /Users/vern/RoR/Portfolio-Project-1-User-Stories/config.ru:in `<main>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (required)>'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
        from /Users/vern/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
    Verns-MacBook-Pro:Portfolio-Project-1-User-Stories vern$ rake db:migrate
    rake aborted!
    You have already activated rake 10.0.4, but your Gemfile requires rake 10.0.3. Using bundle exec may solve this.
    /Users/vern/RoR/Portfolio-Project-1-User-Stories/config/boot.rb:6:in `<top (required)>'
    /Users/vern/RoR/Portfolio-Project-1-User-Stories/config/application.rb:1:in `<top (required)>'
    /Users/vern/RoR/Portfolio-Project-1-User-Stories/Rakefile:5:in `<top (required)>'
    (See full trace by running task with --trace)
    Verns-MacBook-Pro:Portfolio-Project-1-User-Stories vern$ bundle exec rake db:migrate
    rake aborted!
    uninitialized constant ActionController::MimeResponds::ChecksHelper
    /Users/vern/RoR/Portfolio-Project-1-User-Stories/config/environment.rb:5:in `<top (required)>'
    Tasks: TOP => db:migrate => environment
    (See full trace by running task with --trace)
    

1 个答案:

答案 0 :(得分:0)

你可能有

updateRow(line, row);

在某个控制器中。这将使rails尝试从相应的文件中向上实例化一个类。

奇怪的错误消息是因为如果自动加载最终无法找到要加载的合适文件,则错误会显示首次搜索类/常量的初始命名空间。