Forum: Ruby on Rails reloading modules

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3ad14279fd236d3aa03429115835ea21?d=identicon&s=25 Robert K. (robkuz)
on 2006-06-13 19:48
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
Alex Wayne (Guest)
on 2006-06-13 20:13
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.
This topic is locked and can not be replied to.