Reloading modules


#1

hi,

can anybody tell me how i can reload modules automatically
that are living in my …/lib directory?

for the moment i need to shut down rails and restart
to see any changes.

thanks

ciao robertj


#2

robert kuzelj wrote:

hi,

can anybody tell me how i can reload modules automatically
that are living in my …/lib directory?

for the moment i need to shut down rails and restart
to see any changes.

thanks

ciao robertj

For classes you can put an “include Reloadable” in them, but sadly that
does not work for modules.

You either need to restart the server, or explicitly load the files with
the modules in them with the load statement. When testing a module via
the console, I often have a command like:

load ‘lib/some_lib.rb’; SomeLib.some_method

This reloads the library, and does something with it an an easily
repeatable line.

You may be able to add a before_filter that test to see if you are in
development mode, and then if you are, explicity does a ‘load’ on
modules.