Search code examples
rubyrubygemsruby-on-rails-pluginsruby-on-rails-2

A copy of ApplicationController has been removed from the module tree but is still active


Whenever two concurrent HTTP requests go to my Rails app, the second always returns the following error:

A copy of ApplicationController has been removed from the module tree but is still active!

From there it gives an unhelpful stack trace to the effect of "we went through the standard server stuff, ran your first before_filter on ApplicationController (and I checked; it's just whichever filter runs first)", then offers the following:

/home/matchu/rails/torch/vendor/rails/activesupport/lib/active_support/dependencies.rb:414:in `load_missing_constant'

/home/matchu/rails/torch/vendor/rails/activesupport/lib/active_support/dependencies.rb:96:in `const_missing'

which I'm assuming is a generic response and doesn't really say much.

Google seems to tell me that people developing Rails Engines will encounter this, but I don't do that. All I've done is upgrade my Rails app from 2.2 (2.1?) to 2.3.

What are some possible causes for this error, and how can I go about tracking down what's really going on? I know this question is vague, so would any other information be helpful?

More importantly: I tried doing a test run in a "production" environment just now, and the error doesn't seem to persist. Does this only affect development, then, and need I not worry too much?


Solution

  • This is a bug in Rails 2.3.3:

    There is a patch for it (but incomplete?) in 2-3-stable:

    You have a few options to address the problem:

    • Revert to Rails 2.3.2, wait for 2.3.4 to come out, probably at the end of August. 2.3.3 has a couple bad issues, so that might be best.
    • The problem should not happen in production mode, nor will it happen in development mode under the Thin server. If you are having this issue on Google Engines in production mode, the patch is your only hope. If it's only in dev mode, you can just run your local server with Thin instead of Mongrel.
    • If it is Google Engines, you can move off of Google Engines and host your app another way. This seems like a lot of work though.

    Best of luck, this is a really bad bug many people are running into.