Forum: Rails Engines development Making Rails 2.0 reload engine controllers and models

9a183854c4b3cade3d5dd067f457ecfe?d=identicon&s=25 mateo murphy (Guest)
on 2008-02-19 21:26
(Received via mailing list)
Hello,

I've been working on a solution for making rails reload engine
controllers and models. Initially, after a fair amount of googling, I
came up with the following, in development.rb:

config.after_initialize {
  Dependencies.load_once_paths = Dependencies.load_once_paths.select {
|path| (path =~ /app/).nil? }
}

While this solves the problem, I figured it would be even better to do
it within the engines, which lead to this dirty hack:

in engines/lib/engines/plugin.rb, I added the following at the end of
the load method:

      if ::RAILS_ENV == 'development'
        Dependencies.load_once_paths =
Dependencies.load_once_paths.select { |path| (path =~
/#{name}\/app/).nil? }
      end

A possibly cleaner approach would be to monkeypatch the
add_plugin_load_paths method in rail's plugin loader, but it would
just be more code for the same effect.

Any thoughts?

mateo
This topic is locked and can not be replied to.