Skip to content

Instantly share code, notes, and snippets.

@denmarkin
Created April 11, 2011 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denmarkin/913231 to your computer and use it in GitHub Desktop.
Save denmarkin/913231 to your computer and use it in GitHub Desktop.
Example of rails console SQL dumping and result formatting
# dump SQL into console
require 'logger'
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') # rails 2
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT))
else # rails 3
ActiveRecord::Base.logger = Logger.new(STDOUT) if defined? Rails::Console
end
# enable result formatting - install gem 'hirb'
require 'hirb'
Hirb.enable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment