Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 engine and code reloading in development mode

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.

like image 926
miros Avatar asked Apr 09 '11 08:04

miros


1 Answers

It's an old question but I think adding ActiveSupport::Dependencies.explicitly_unloadable_constants += %w[ GemName ] to your development.rb should do the trick.

like image 113
Cojones Avatar answered Oct 14 '22 14:10

Cojones