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
- 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
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 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.