In application.rb, I have
config.autoload_paths += %W(#{config.root}/lib
So when I modify a class under lib, my code is reloaded.
However, when I tried adding config/initializers to autoload, I noticed my code doesn’t get updated.
If I’m writing an extension for the string class, I have to restart rails every time I modify my code.
Please advise?
Initializers are only loaded when starting rails (and never reloaded). When tinkering in
config/initializersyou will have to restart rails every time.Of course, you could make sure your code is defined in
/libso you can still make sure it works, by using your test-suite.E.g. in
lib/speaker.rbwriteand in your initializer you could then do something like
While this will still only get loaded when starting rails, you can develop and test your module more easily.
Hope this helps.