I wrote custom instrumentation in my Rails application. I enable it in config/initializers/instrumentation.rb
file like this:
ActiveSupport.on_load(:action_controller) do
include FooBar::ControllerRuntime
end
But this leads me to errors A copy of FooBar::ControllerRuntime has been removed from the module tree but is still active!
. I figure it out that I can resolve it in two ways:
- Adding path where may 'FooBar::ControllerRuntime
is defined to
config.autoload_one_paths` - Defining
:to_prepare
callback inActionController::Railtie
Second solution looks like this:
config.to_prepare do
ActionController.include FooBar::ControllerRuntime
end
This long introduction leads to question: which way is better? With first I am disabling reloading of classes which lay in the same path as my FooBar::ControllerRuntime
. With second I don't feel it is good to messup with ActionController::Railtie
. Right know ActionController::Railtie
doesn't have defined to_prepare
but what happend if in next release it will have?