Where to override ActiveRecord

I want to reopen the ActiveRecord::Base class in a Rails environment and is wondering about the best place to put the code. The new and altered methods should be used by all instances in the whole Rails application. Any ideas?

Thanks in advance

Erik Lindblad

Your app has a lib folder for this kind of stuff.

Any .rb files you put in lib will be automatically required. So if you just did

lib\active_record_patches.rb

module ActiveRecord class Base def self.foo “hello world” end end

end

That should be it.

User.foo => “hello world”

Thanks, just what I needed.

Regards

Erik

Great advice, one question:

Is this documented anywhere? None of my documentation seems to have it.

fredistic

Great advice, one question:

Is this documented anywhere? None of my documentation seems to have it.

fredistic