Use Active Record 3 (3.0.0 beta 3) without Rails and custom Logger
Just in case you try to use Active Record 3 without Rails but you want the same fancy logging.
You have to require not only active_record, but also active_record/railtie. Took me a while to find this out.
require 'rubygems'require 'active_record'require 'active_record/railtie'require 'logger'
class MyClass
def initialize
@log = Logger.new(File.dirname(__FILE__) + '/../debug.log') @log.level = level = Logger::DEBUG @log.datetime_format = "%Y-%m-%d %H:%M:%S"
ActiveRecord::Base.logger = @log
#ActiveRecord::Base.establish_connection ... and so on...
end
endMaybe this saves you some time and hassle…










No Comments, Comment or Ping
Reply to “Use Active Record 3 (3.0.0 beta 3) without Rails and custom Logger”