Class extensions in lib not loading


I'm using 2.0.2.

If I add a class to ./lib, the class is created and I can access it on

However, if I extend a (core) class using a file in lib, the class
extension does not occur. The methods I want to add do not appear.
If I explicitly load the class, the methods get added. But they are
not done automatically like with other things in lib. Why?

Or, more to the point: What is the correct Rails way to add a method
to a core Ruby class?


I'm seeing the same issue. To get around it I require the file
directly in config/environment.rb.

For example, I have the file 'lib/module.rb' which looks like this:

class Module
  include ModuleExtensions

For some reason this file is not auto loaded. It also seems to happen
with any other class in the core library I try (Integer, etc.).

So in my environment.rb:

require 'lib/module'

It would be nice to know if there is a nicer (conventional) way to do


For extending core classes you've got the main one right there. One
thing to keep in mind is that files are only read out of /lib at
startup... that is when you first fire up the console or Rails
webserver. If you make changes to the file you'll have to reload! (in
console) or restart the webserver.