Using ruby-debug with Pow
Published almost 2 years ago
After moving to Sam Stephenson’s awesome Pow, not being able to use ruby-debug was the primary obstacle I had adjusting to my new development environment. But as it turns out, it’s very simple to use ruby-debug with Pow.
gem 'ruby-debug19' # 'ruby-debug' if using Ruby 1.8
unless $rails_rake_task require 'ruby-debug' Debugger.settings[:autoeval] = true Debugger.settings[:autolist] = 1 Debugger.settings[:reload_source_on_change] = true Debugger.start_remote end
This will start a debugger server.
[lifo@null ~]$ rdebug -c Connected.
You should now see a ruby-debug console whenever the application hits a breapoint.
If you don’t want to bother your co-workers with the ruby-debug stuff, you can configure a global .gitignore file and setup ruby-debug from an initializer that’s ignored via the global .gitignore.
$ git config --global core.excludesfile ~/.gitignore $ echo my_super_secret_ruby_debug_initializer.rb >> ~/.gitignore
# config/initializers/my_super_secret_ruby_debug_initializer.rb if (Rails.env.development? || Rails.env.test?) && !$rails_rake_task require 'ruby-debug' Debugger.settings[:autoeval] = true Debugger.settings[:autolist] = 1 Debugger.settings[:reload_source_on_change] = true Debugger.start_remote end
You’ll still need to have ruby-debug in Gemfile. But I imagine that’ll go unnoticed!
If you are not religiously using ruby-debug already, you are certainly missing out. Here are a few resources that should help you get started:
UPDATE 1: Added $rails_rake_task checks to make sure not to start the debugger for rake tasks