I have a rails application that patches ActiveRecord with a hand-coded
The patch is made by adding the following lines in config/
Rails::Initializer.run do |config|
This works fine in production mode i.e. with
config.cache_classes = true
however it does not work in development with cache_classes set to
The error thrown is
ArgumentError (A copy of MtLib::DBValidations has been removed
the module tree but is still active!):
My question is what is the process that is followed when cache_class
is set to false. Does Rails re-run any of the initialization methods?
If not then where is the best place for me to put my patch to ensure
that it is in all models and survives a classes reload?
I have tried adding the patch to config/initializers/
active_record_patch, however this is not re-run when the classes are