Rails->breakpointer->irb->debugger?

D

Dan Bensen

How do you step through your Rails code from irb? Can you drop
into the debugger, or do you have put in a zillion breakpoints?
Is there a way to add & delete breakpoints from irb,
or do you have to set them all before you request a page?
 
A

A. S. Bradbury

How do you step through your Rails code from irb? Can you drop
into the debugger, or do you have put in a zillion breakpoints?
Is there a way to add & delete breakpoints from irb,
or do you have to set them all before you request a page?

I think you'll like ruby-breakpoint[1]. Just put 'breakpoint' anywhere in your
code, and at that point you'll drop to an irb session where you can inspect
variables, and basically do whatever you want.

If that's not what you want, try googling for tutorials on using the Ruby
debugger.

Regards,
Alex

1. http://ruby-breakpoint.rubyforge.org/
 
G

Geoff Davis

How do you step through your Rails code from irb? Can you drop into the
debugger, or do you have put in a zillion breakpoints? Is there a way to
add & delete breakpoints from irb, or do you have to set them all before
you request a page?

Check out ruby-debug.

http://www.datanoise.com/articles/2006/07/12/tutorial-on-ruby-debug

http://blog.nanorails.com/articles/2006/07/14/a-better-rails-debugger-ruby-debug

The docs are a little out of date -- you'll also need to call
Debugger.start before your debugger call.
 
R

Rick DeNatale

Check out ruby-debug.

I finally got around to trying this, I'd installed the gem some time ago.

I tried it on a ruby script which takes parameters, but it doesn't
seem to work, the usage seems to indicate that you can give parameters
after the script name but rdebug seems to parse and choke on them
itself.

$ rdebug myscript -b 10
ruby-debug 0.4.1
Usage: rdebug [options] <script.rb> <script.rb parameters>

Options:
-s, --server Listen for remote connections
-w, --wait Wait for a client connection,
implies -s option
-n, --nostop Do not stop when a client
connects, implies -s option
-c, --client Connect to remote debugger
-h, --host HOST Host name used for remote debugging
-p, --port PORT Port used for remote debugging
--script FILE Name of the script file to run
--cport PORT Port used for contol commands,
implies -s option

Common options:
--help Show this message
-v, --version Show version

invalid option: -b
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top