How to debug ruby on rails code

Hi Everyone,

Can any one help me in debugging code in ruby on rails. I am using
Ruby 1.8.4 and radrails 0.7.2 IDE …

PLease give me some guidence in debugging the ruby code in radrails
IDE(0.7.2 version)…

Regards
Krishna.Mundra

for print outs in the controller

logger.debug = “something” + variable…

in view i use

<%= debug(@something)%>

Krishna M. wrote:

Hi Everyone,

Can any one help me in debugging code in ruby on rails. I am using
Ruby 1.8.4 and radrails 0.7.2 IDE …

PLease give me some guidence in debugging the ruby code in radrails
IDE(0.7.2 version)…

Regards
Krishna.Mundra

oh yea, i also use “tail -f development.log” in the log directory.

tailing is good, this is better… :wink:
i’m using it on windows, so i don’t know how it will work on linux. :wink:

more information here:

thanks to Kyle


install this:
gem install ruby-debug

run server like this:
rdebug script/server

set breakpoints in your application like this:
debugger if ENV[‘RAILS_ENV’] == ‘development’

short indroduction:
if redbug is started, use help for displaying available commands.

most important commands at starting:
set autolist
set autoeval
set autoreload

or create a ~/.rdebugrc wiht these commands to execute them
automatically.

(rdb:1) help
ruby-debug help v.0.7.5
Available commands:
backtrace break catch cont delete display down eval exit finish frame
irb list method next p pp quit reload restart save script set step
trace undisplay up var where

help [command] => shows help for [command]

pretty nice to use and fast.
will be integrated into RadRails with the next release. so i hope.

enjoy developing RoR again. :slight_smile:

HTH