Ruby-on-rails – Best way to load module/class from lib folder in Rails 3

autoloadclassmoduleruby-on-railsruby-on-rails-3

Since the latest Rails 3 release is not auto-loading modules and classes from lib anymore,
what would be the best way to load them?

From github:

A few changes were done in this commit:

Do not autoload code in *lib* for applications (now you need to explicitly 
require them). This makes an application behave closer to an engine 
(code in lib is still autoloaded for plugins);

Best Answer

As of Rails 2.3.9, there is a setting in config/application.rb in which you can specify directories that contain files you want autoloaded.

From application.rb:

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)