Skip to content

Instantly share code, notes, and snippets.

@prathamesh-sonpatki
Created January 24, 2013 05:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prathamesh-sonpatki/4617941 to your computer and use it in GitHub Desktop.
Save prathamesh-sonpatki/4617941 to your computer and use it in GitHub Desktop.
-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