public
Description: Rack::Debug is middleware that provides a simple interface to ruby-debug. Helps debug apps running in Passenger.
Homepage: http://ddollar.github.com/rack-debug
Clone URL: git://github.com/ddollar/rack-debug.git
Click here to lend your support to: rack-debug and make a donation at www.pledgie.com !
name age message
file .gitignore Tue May 19 09:34:35 -0700 2009 gemify [David Dollar]
file README.rdoc Wed Nov 11 16:01:58 -0800 2009 update docs to reflect gemcutter hosting [David Dollar]
file Rakefile Thu Nov 05 16:27:20 -0800 2009 update rakefile to correct typos and to add new... [David Dollar]
file VERSION Thu Nov 05 16:27:31 -0800 2009 Version bump to 1.4.1 [David Dollar]
directory lib/ Thu Nov 05 16:23:32 -0800 2009 better handling of :socket_path option [David Dollar]
file rack-debug.gemspec Thu Nov 05 16:27:56 -0800 2009 update gemspec [David Dollar]
README.rdoc

Install

 $ gem install rack-debug --source http://gemcutter.org

Rails

 # config/environments/development.rb
 config.gem 'rack-debug', :source => 'http://gemcutter.org'
 config.middleware.use 'Rack::Debug'

 # RAILS_ROOT/Rakefile
 require 'rack-debug/tasks'

Middleware

 # add a use line to your builder
 require 'rack/debug'
 Rack::Builder.new do
   use Rack::Debug
   run MyApp.new
 end

 # can optionally specify where to put the sockets
 use Rack::Debug, :socket_path => '/tmp/rack-debug'

 # Rakefile
 require 'rack-debug/tasks'

Add breakpoints to your code

 @user = User.find(params[:id])
 debugger
 render :show

Debugging:

 # run the rake task,
 $ rake debug
 Connected.

 # refresh a page in your browser, your app will break at debugger statements
 (rdb:1) p @user
 #<User id: 1, name: "David Dollar", email: "ddollar@gmail.com", created_at: "...", updated_at: "...">

 # can specify the socket path
 SOCKET_PATH=/tmp/rack-debug rake debug

Thanks to:

  Rack::Bug for a good example of Rack middleware in Rails
  Ben Scofield for making me want to build some Rack middleware