Rails Engines and the “A copy of ApplicationController has been removed from the module tree but is still active!” error



This was a beast of an error to get around, but finally I did in a not so clean manner. I’ve been working with Rails Engines and the approach was to make all controllers in my engine path “unloadable” per the last comment in this thread:

http://dev.rubyonrails.org/ticket/6001

Not the cleanest approach, but it will work until I can actually understand the core problem and refactor my code. This should at least buy you some time so that you can focus on creating modular Rails Engines!



3 Responses to “Rails Engines and the “A copy of ApplicationController has been removed from the module tree but is still active!” error”

  1. Boris says:

    I had the same problem. I solved it by adding the line:

    config.cache_classes = false

    in my config/environments/development.rb file. That had the unfortunate effect of requiring me to restart my development server whenever I wanted to add new changes. I think it’s a cleaner solution, but it definitely causes a lot of trouble when developing.

  2. dennis says:

    Okay, but doesn’t that only fix your problem for development purposes? I’m assuming you don’t disable your class cache in a staging or production env. Would love to hear more about what you’re doing and I agree that approach is a hassle during development :) Thanks for sharing.

  3. Horace Ho says:

    config.cache_classes = false

    is in development.rb by default, I guess the Boris means:

    config.cache_classes = true

    which (seems) fix my issue when mixing authlogic and smerf

Leave a Reply