# Reloading of lib files in development mode

**URL:** <https://www.ruby-forum.com/t/reloading-of-lib-files-in-development-mode/106500>\
**Category:** Engines\
**Created:** [June 11, 2007, 11:32am UTC](https://www.ruby-forum.com/t/reloading-of-lib-files-in-development-mode/106500 "2007-06-11T11:32:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![reven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/87869e/32.png) [@reven](https://www.ruby-forum.com/u/reven)\
**Post date:** [June 11, 2007, 11:32am UTC](https://www.ruby-forum.com/t/reloading-of-lib-files-in-development-mode/106500/1 "2007-06-11T11:32:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![reven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/87869e/32.png) [@reven](https://www.ruby-forum.com/u/reven)\
**Post date:** [October 2, 2007, 8:16am UTC](https://www.ruby-forum.com/t/reloading-of-lib-files-in-development-mode/106500/2 "2007-10-02T08:16:21Z")

</div>

Hi yohann,

You can see how I managed to do something similar here:  
[http://www.williambharding.com/blog/?p=84](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
