I have a rails 3 engine. In initializer it requires a bunch of files from some folder. In this file user of my engine defines code, business logic, configures engine, etc.. All this data is stored statically in my engine main module (in application attribute)
module MyEngine
class << self
def application
@application ||= MyEngine::Application.new
end
end
end
I want this files to be reloaded on each request in development mode. (So that the user don't have to reload server to see changes he just made) Of course I can do something like this instead of initializer
config.to_prepare do
MyEngine.application.clear!
load('some/file')
end
But this way i will have issues (because constants defined in this file won't really be reloaded).
The ideal solution would be to make my whole engine reloadable on each request, but a have not found the way to do it.
It's an old question but I think adding ActiveSupport::Dependencies.explicitly_unloadable_constants += %w[ GemName ]
to your development.rb should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With