Created
April 11, 2011 08:38
-
-
Save denmarkin/913231 to your computer and use it in GitHub Desktop.
Example of rails console SQL dumping and result formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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