简体   繁体   中英

uninitialized constant ActionController

Backstory: Some friends and I were working on an app and wanted to select multiple items for processing on another page. Before we found RailsCast #165 , I created a branch and added scaffold for a table with three checkboxes on it just to see what the generated code looked like. Having found the right answer in RC165, I deleted all the code, and the migration, with the intention of abandoning all that work.

Alas, I can't seem to get rid of it as references to it prevent me from doing anything on any branch at all. When I "rake db:migrate" or "rails s" or anything, I get ...

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

... even though the character string "Checks" does appear anywhere in my project directory. I have gone so far as to:

  1. Rename the directory and clone a new project from github (Note: my experiment was never commited even at the local file system level, much less pushed up).
  2. Blow away the Postgress development and test databases

I am at a complete loss to understand how and where Rails is "remembering" my brief experiment and am out of ideas short of blowing away Ruby, Rails, and rbenv, ie scraping the machine to bedrock - yuck.

I can't believe that simply backing away from some ill-considered code should be this hard.

Any suggestions on how to solve this or avoid it in the future would be most welcome.

-- Vern

Stack traces follow:

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)

You might possibly have

helper :checks

in some controller. This will make rails try to instantiate a class from a corresponding file and upwards.

The weird error message is because if autoload finally fails to find a suitable file to load, the error shows the initial namespace where the class/constant was first searched in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM