views:

2021

answers:

5

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?

A: 

Weird.

Trying running "rake rails:update" to make sure the configs are scripts are up to date. You may have to check the existing ones against a template application.

askegg
No output on the rake task =/
Matchu
Damn. I have never seen this before, and I see what you mean about Engines causing the error. Hopefully someone else might be able to help. Sorry :(
askegg
A: 

i had this error and from memory it was one of one of these three things that fixed it.

1) I needed to update mongrel/rack 2) I had an environment variable from restful authentication that i had moved into the production.rb and development.rb files from the environment.rb - shifting it back to environment.rb seemed to help 3) will_paginate was out of date

ADAM
+8  A: 

Hi Matchu,

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.

mixonic
Oh wow, good to know it's not me. I think I'll just sit out and wait, since this app will be deployed in a month or so, but even if it's not out, having the upgrade only really matters for my sanity. Thanks for letting me know I'm not the only one!
Matchu
Using either WEBrick or Thin server or Mongrel will not solve the problem. I have tried all the three servers but still the problem exists.
Shree
Shree I know avoiding mongrel was a recommended fix and work for several people I know. Are you on Rails 2.3.3? Are you sure it's the same issue?
mixonic
+1  A: 

I addition to the workarounds mentioned in the other answers, I have encountered two others:

  1. Add "config.cache_classes = false" to your config/environments/development.rb file. This has the unfortunate side effect of requiring you to restart your server whenever you want to see your changes.
  2. Add 'unloadable' inside your controller classes in your engine. See http://strd6.com/?p=250 and http://dev.rubyonrails.org/ticket/6001

I haven't tried the second approach, since I found the other solution first, but there is of course a trade-off between avoiding having to edit plugin code, which may be reverted if a newer version of the plugin is downloaded, and then the ease of development provided by not having to restart the development server all the time in the second solution.

Boris
+1  A: 

i faced with same problem for my new engine on rails 2.3.4 and i found solution here.

calling unloadable method solved my problem.

airy