Reloading of lib files in development mode

Hi,

I’ve been using engines for one month now and find it perfect so far, it
helped me a lot to keep separate my admin interface code from the main
app. Congratulation for this plugin !

I do use some modules to keep my code DRY,

in a normal rails app I reload my modules after each request using this
line of code in development.rb

require_dependency RAILS_ROOT + “/lib/my_module”

My engines views and controller are reloaded automatically after each
request if I ad those 2 lines of code in develoment.rb

Dependencies.mechanism = :load
Dependencies.load_once_paths.delete(Dir[RAILS_ROOT + ‘/vendor/plugins’])

But I don’t find any solution to reload modules when they are included
in the lib folder of an engines…I have to keep them in the main app
lib folder to force reload in development mode.

Anyone would know how to force reloading per request of the lib files in
an engine ?

thanks a lot,

yohann

Hi yohann,

You can see how I managed to do something similar here:
http://www.williambharding.com/blog/?p=84

I think the trick is requiring the correct directory (i.e., that of your
engine’s lib), and making sure that Rails knows which Module it is
supposed to reload every time (for me, simply deleting the once_paths
didn’t work. The blog discusses this). If you add a line similar to
your

require_dependency RAILS_ROOT + “/lib/my_module”

But where you replaced the ‘RAILS_ROOT + “/lib/my_module”’ with the path
to the lib file in your engine folder, I think you’d be on the right
track.

Bill

yohann patri wrote:

Hi,

I’ve been using engines for one month now and find it perfect so far, it
helped me a lot to keep separate my admin interface code from the main
app. Congratulation for this plugin !

I do use some modules to keep my code DRY,

in a normal rails app I reload my modules after each request using this
line of code in development.rb

require_dependency RAILS_ROOT + “/lib/my_module”

My engines views and controller are reloaded automatically after each
request if I ad those 2 lines of code in develoment.rb

Dependencies.mechanism = :load
Dependencies.load_once_paths.delete(Dir[RAILS_ROOT + ‘/vendor/plugins’])

But I don’t find any solution to reload modules when they are included
in the lib folder of an engines…I have to keep them in the main app
lib folder to force reload in development mode.

Anyone would know how to force reloading per request of the lib files in
an engine ?

thanks a lot,

yohann