Created
January 24, 2013 05:37
-
-
Save prathamesh-sonpatki/4617941 to your computer and use it in GitHub Desktop.
This file contains 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
-T | |
-d postgresql | |
def change_log(stream) | |
# send Rails logs to console | |
# 2.X | |
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
Object.const_set 'RAILS_DEFAULT_LOGGER', Logger.new(stream) | |
end | |
# 3.X | |
ActiveRecord::Base.logger = Logger.new(stream) if defined? Rails::Console | |
ActiveRecord::Base.clear_active_connections! | |
end | |
def show_log | |
change_log(STDOUT) | |
end | |
def hide_log | |
change_log(nil) | |
end | |
def sql(query) | |
ActiveRecord::Base.connection.select_all(query) | |
end | |
# includes Rails routes helpers | |
def rails_routes | |
include ActionController::UrlWriter | |
default_url_options[:host] = 'example.com' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment