Skip to content

Instantly share code, notes, and snippets.

@kbrock
Created April 8, 2011 03:36
Show Gist options
  • Save kbrock/909234 to your computer and use it in GitHub Desktop.
Save kbrock/909234 to your computer and use it in GitHub Desktop.
initializer to load debugger
#lib/tasks/debugger.rake
task :restart do
system("touch tmp/restart.txt")
end
task :debug => :restart do
system("touch tmp/debug.txt")
puts "after hitting a page, type `rdebug -c` to debug"
end
# or
# bundle exec rdebug -c
# config/initializers/debugger.rb
if Rails.env.development?
if File.exists?(File.join(Rails.root,'tmp', 'debug.txt'))
require 'rdebug/base'
require 'ruby-debug'
Debugger.wait_connection = true
Rails.logger.debug('Waiting for debugger: type `rdebug -c` to debug')
Debugger.start_remote
Rails.logger.debug('debugger connected')
File.delete(File.join(Rails.root,'tmp', 'debug.txt'))
end
end
gem 'rdebug', '0.1', :group => :development, :require => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment