Skip to content

Instantly share code, notes, and snippets.

@rafbm
Created May 22, 2014 15:52
Show Gist options
  • Save rafbm/5444eab341ffd60c2146 to your computer and use it in GitHub Desktop.
Save rafbm/5444eab341ffd60c2146 to your computer and use it in GitHub Desktop.
Net::HTTP provides instance-level debugging. Here’s how to toggle it globally with `Net::HTTP.debug=`.
# config/initializers/net_http_debug.rb
if Rails.env.development?
require 'net/http'
Net::HTTP.class_eval do
class << self
attr_accessor :debug
end
prepend Module.new {
def initialize(*args)
super
set_debug_output(STDERR) if self.class.debug
end
}
end
Net::HTTP.debug = true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment