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

Posted by 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.