views:

992

answers:

3

Hi All,

Is there any way in Rails to have the ENV reload "lib" files without having to restart the server? I'm working with some classes that I have inside a module in "lib". However, in order to see my changes I must restart the server each time. I'm guessing this is the way Rails is intended to work, but it is quite tedious when developing library files and/or plugins.

Surely I'm going about this wrong....?

Best

EDIT 1

Neither answer 1 nor 2 worked for me. Instead I was presented with errors from the controllers that made use of the Module. FYI, I have 3 files in my "lib/xmlitems" directory. I attempted to load that subdirectory then I referenced the single file that "requires" all other files. Am I to individually load all files?

A: 

Maybe http://www.williambharding.com/blog/rails/automatically-reload-modules-on-change-in-rails/ answers your question.

Hope this helps.

txwikinger
A: 

Also answered in this question.

Shadwell
A: 

Slightly hacky but .. you could move it into your models folder for now, then move back into lib when you are done developing.

You shouldn't really think about monkey patching rails so that you can reload your lib folder. Just leave it as is.

Omar Qureshi
That hilarious, I'd actually been doing that previously, but I wanted to go ahead and get the code into a proper state for upcoming deployment. Anyway, I might actually got back to that for the last couple weeks of dev.
humble_coder