# Desarrollo de plugins: ¡Se ha eliminado una copia de ApplicationController del árbol de módulos pero sigue activa!

**URL:** <https://meta.discourse.org/t/plugin-development-a-copy-of-applicationcontroller-has-been-removed-from-the-module-tree-but-is-still-active/98584>\
**Category:** Development\
**Created:** [2 Octubre, 2018 22:32 UTC](https://meta.discourse.org/t/plugin-development-a-copy-of-applicationcontroller-has-been-removed-from-the-module-tree-but-is-still-active/98584 "2018-10-02T22:32:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)\
**Post date:** [2 Octubre, 2018 22:51 UTC](https://meta.discourse.org/t/plugin-development-a-copy-of-applicationcontroller-has-been-removed-from-the-module-tree-but-is-still-active/98584/2 "2018-10-02T22:51:01Z")

</div>

I believe this is related to rails code reloading, and shouldn’t have to do with your naming. Something like the following happens:

- You start the app
- It loads up the core .rb files and stores the resultant classes into constants (like `ApplicationController`)
- Those classes refer to other classes, which are then loaded into constants in the same way (like `BaseController` if you have `ApplicationsController < BaseController`)
- These classes are singletons, meaning only one of them exists in the world, and are uniquely referred to by their class name. Rails keeps track of which constants you’ve defined and loads them automatically when you reference them.

Rails also automatically re-defines most of these constants when you change things. So, if you change the code for `BaseController`, rails will automatically determine that constant is stale, refresh the definition from your code, as well as any classes referencing that file (so, `ApplicationsController` will be reloaded as well to account for the new reference to `BaseController`)

This works great, _until_ you are dealing with classes which are not hot reloaded. A common example with a typical rails app is putting things into the `lib` directory (rather than the `app` directory), which are not automatically reloaded by default. So this situation arises when you have a file in `/lib` which references a file in `/app`, the `/app` file is changed, but the `/lib` file is not, leaving it pointing to a class which has been removed from the list of classes defined in the rails app.

I’ve run into this as well very occasionally with Discourse in the past, but didn’t have the gumption to troubleshoot it too hard. But, as a start, I believe you have a case where some of your plugin code is not being reloaded (maybe something needs to be added to autoload\_paths?), and is breaking when it references some constant which _is_ hot reloaded.

---

_[View the full topic](https://meta.discourse.org/t/plugin-development-a-copy-of-applicationcontroller-has-been-removed-from-the-module-tree-but-is-still-active/98584)._
