Monkeypatching ActiveRecord so 'logger' Works Seamlessly

Posted on February 18, 2008

Ever tried calling “logger.info” from an ActiveRecord object, only to have rails lay the smack-down on ya?

Use ‘logger’ seamlessly throughout your app with this monkey patch:

module ActiveRecordExtensions

  def logger
    RAILS_DEFAULT_LOGGER
  end

end

class ActiveRecord::Base
  include ActiveRecordExtensions
end

Throw that in environment.rb or wherever you keep your monkey patches, and let the good times roll.