bdunagan

fill the void - bdunagan

06 Oct 2011
Rack Tip: ActiveRecord with Logging

Using ActiveRecord in Rack is one line of Ruby code, and setting up database logging outside of Rails is just as easy. As a minor extension of this excellent tidbit, you simply instantiate the Logger object with a file path. Here's the code:

require 'active_record'
require 'active_support'
ActiveRecord::Base.logger = Logger.new("log/db.log")
# ActiveRecord::Base.establish_connection(...)
Previous LinkedIn Twitter GitHub Email Next