是否可以单步执行RoR应用程序?或者只使用调试断点进行调试?

时间:2010-10-18 20:31:54

标签: ruby-on-rails debugging

我读到你可以在你的RoR代码中加上一个'调试'符号,然后执行将在那时停止,然后你可以向控制台吐出任何东西以查看变量的状态等。

有没有办法逐步执行每一行并遵循执行路径?

2 个答案:

答案 0 :(得分:5)

调试器本身有文档。 ns是您要查找的命令。

(rdb:1) help
ruby-debug help v0.10.3
Type 'help <command-name>' for help on a specific command

Available commands:
backtrace  delete   enable  help    next  quit     show    trace    
break      disable  eval    info    p     reload   source  undisplay
catch      display  exit    irb     pp    restart  step    up       
condition  down     finish  list    ps    save     thread  var      
continue   edit     frame   method  putl  set      tmate   where    

(rdb:1) help next
n[ext][+-]?[ nnn]   step over once or nnn times, 
        '+' forces to move to another line.
        '-' is the opposite of '+' and disables the force_stepping setting.
(rdb:1) help step
s[tep][+-]?[ nnn]   step (into methods) once or nnn times
        '+' forces to move to another line.
        '-' is the opposite of '+' and disables the force_stepping setting.
(rdb:1) 

答案 1 :(得分:0)

这个Railscast episode也有一些关于ruby-debug的提示。