From: "Ball, Donald A Jr (Library)" Date: 2007-01-24T04:14:28+09:00 Subject: wrapping class method Hey guys, I'm having trouble figuring out how to wrap a class method. I want to add a logger.debug to ActiveRecord::Base.establish_connection, just trying to figure out how the rails database connection lifecycle is supposed to work. I tried this naive approach: module ActiveRecord class Base alias self.old_establish_connection self.establish_connection def self.establish_connection(arg) logger.debug("Establishing connection") self.old_establish_connection(arg) end end end of course, ruby doesn't like this, the self.old_establish_connection bit throws a SyntaxError. How ought I go about doing this? - donald