没人维护,bug多。Ruby 1.9.3后不推荐使用html
ruby 1.9.3后的选择,功能强大,缺点是没有语法高亮。git
修改Gemfilegithub
1 2 3 |
group :development, :test do gem 'debugger' end |
在须要设置断点的地方:ruby
1
|
require 'debugger'; debugger |
1 2 3 |
list #日后翻看代码 list- [n] #往前翻看代码 list= #查看当前运行处代码 |
list能够缩写为lapp
1 2 3 |
backtrace/where # 查看 frame [n] # 跳到指定stack frames up [n] (缩写u) 和 down [n] # 在stack frames层里来回切换 |
1 2 3 4 |
next # 执行下一行,遇到方法调用不进入。 step # 执行一步,遇到方法调用进入。 continue/c # 执行到下一个断点。 finish [n] # 执行到指定的frame才返回。注意编号是从下往上数。 |
1 2 |
help info |
替代irb,我最喜欢的是语法高亮。ide
1 2 3 4 5 6 7 8 |
help cd .. whereami self ls show-doc show-method edit-method |
pry只是替代erb,并不能调试rails,加上rails后便可pry-nav。 增长3种基本调试指令。ui
1 2 3 |
step next continue |
Pry的插件,用于查看方法栈spa
1 2 3 4 5 6 7 |
(pry) main: 0> show-stack Showing all accessible frames in stack (5 in total): -- => #0 [method] gamma #1 [method] beta #2 [method] alpha |
修改Gemfile插件
1 2 3 4 5 |
group :development, :test do gem 'pry' gem 'pry-nav' gem 'pry-stack_explorer' # 若是不查看方法栈,能够省略 end |
在须要设置断点的地方:debug
1
|
binding.pry |
https://github.com/cldwalker/debugger
https://github.com/pry/pry-stack_explorer
http://guides.rubyonrails.org/debugging_rails_applications.html