Prev | Current Page 81 | Next

Brad Ediger

"Advanced Rails"

../gems/ruport-1.2.0/lib/ruport/data/table.rb:805 table=
(rdb:1)
The irb command (still experimental) will start up an interactive Ruby session
within the context of the current code, allowing you to examine the environment:
.../gems/ruport-1.2.0/lib/ruport/data/table.rb:805 table=
(rdb:1) irb
>> pp args
["time.csv"]
=> nil
>>
The help command will show you information on the available command language
??”there are several more commands and options available.
Debugging Rails with ruby-debug
Now that we understand the basics of the debugger console, we can see how it integrates
with Rails. The process is quite simple and easy; ruby-debug is built to be used
with Rails with virtually no setup.
1. Require the ruby-debug library from config/environments/development.rb so that
it is only loaded in the development environment:
require 'ruby-debug'
2. Insert a call to debugger anywhere you want to stop the application??™s execution
and drop into the debugger.
class SignupController < ApplicationController
def check_for_service
debugger
@query = params[:q]
(...)
3. Start up the Rails server. The debugger only works with WEBrick and Mongrel,
because the running code still has access to the tty under those servers.
How to Read Code | 55
Under FastCGI, the worker processes would not be able to interact with the
console.
$ script/server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.


Pages:
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93