I have a Rails code that doesn't fit neatly in a model or controller field. Since this answer , I created the app/classes directory. Rails 3 seems to automatically add this to the “boot path” in Rails, and my application correctly finds the classes that I define there, without using require statements.
However, the code in app/classes does not reload in development mode; if I made a change, I need to restart the server to see this change.
What is the correct way to make this directory "reloaded" in Rails 3.2.x? A few recommendations here recommend:
config.autoload_paths += %W(
but I believe that this simply leads to adding app/classes to the original set of directories to search for code in; doesn't seem to make them rebootable for every request (and, moreover, in 3.x it seems that app/* automatically added).
Update :
Figures, I came across a solution just 30 seconds after posting the question:
I had a class wrapped inside a module. As soon as I removed the surrounding "MyModule", it suddenly began to recharge. Based on the Java background and being burnt out of Ruby code that pollutes the global namespace, I developed the habit of putting everything into a module. I believe that the Rails “application” code should be outside of any module?
George Armhold
source share