Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
Ask: do I want to namespace modules and classes inside my new dir? For example in app/models/products/ you would need to wrap your class in a module Products.
If the answer is yes, do nothing. It will just work.
If the answer is no, add config.autoload_paths += %W( #{config.root}/app/models/products )
to your application.rb.
If you put something in the lib/ dir, what you are saying is: "I wrote this library, and I want to depend on it where I decide." This means that if you use your library in a rake task, but not in a rails app, you just require it in your rake task. If you need this library to always be loaded for your rails app, you require it in an initializer. If you need this library for some of your models or controllers, you require it in those files, and since everything under your app is already auto- and eager-loaded as needed, in development your library will only be pulled in if a constant that requires it was triggered.
Another option is to add your whole lib dir into autoload_paths
: config.autoload_paths += %W( #{config.root}/lib )
. This means you shouldn't explicitly require your lib anywhere. As soon as you hit the namespace of your dir in other classes, rails will require it. The problem with this is that in Rails 3 autoload paths are not eager loaded in production. And in ruby 1.9 autoload is not threadsafe. You probably want eager loading in production. Requiring your lib explicitly, like in option 1, is akin to eager loading it, which is threadsafe.
In your lib/ dir you should structure your code as if you structure a gem. If you need more than 1 file, you could for example add a same-named directory where everything is properly namespaced, and let your 1 file relatively require files in that directory.
Thank you! This posting finally explained what I was looking for.