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
bphogan
(Brian P. Hogan)
November 13, 2007, 4:11am
2
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
fredistic
(fredistic)
November 14, 2007, 12:47pm
4
Great advice, one question:
Is this documented anywhere? None of my documentation seems to have
it.
fredistic
fredistic
(fredistic)
November 14, 2007, 1:18pm
5
Great advice, one question:
Is this documented anywhere? None of my documentation seems to have
it.
fredistic