Does anyone know how to instruct rails to NOT cache classes that are included within the lib folder?
By "caching classes" I suppose you mean that source files inside the app directory are automatically reloaded in development environment before a new request is processed?
This is not related to caching, the normal behavior of Ruby is, to read and parse a source file once and never again as long as the process runs. Rails (ActiveSupport::Dependencies actually) provides a mechanism to reload the whole code before a request is processed. In development environment, this is useful since you don't want to restart the local webserver for every change you do to the code. In production environment this would badly hurt performance and is turned off therefore.
By default, the app classes are marked as reloadable. You can mark arbitrary classes to be reloaded before a request is processed in development environment by using the unloadable
class method:
class MyClass
unloadable # mark this class as reloadable before a request is processed
# …
end
Beware that not every class may play well with unloading. As long as you define your class in one source file that gets found and loaded by Rails' autoloading mechanism, you're probably good. But can run into troubles if you re-open your class elsewhere to monkeypatch it since autoloading won't catch this.