Debugging rails with ruby-debug
1. setup
$> sudo gem install ruby-debug
2. start rails webrick/mongrel web server
$> script/server --debugger
3. using debugger in controller
class PeopleController < ApplicationController def new debugger # 当应用程序访问到此行时,在console中会出现debugger控制台 @person = Person.new end end
4. debugger shell 命令帮助
(rdb:40) help
ruby-debug help v0.10.3
Type 'help' for help on a specific command
Available commands:
backtrace delete enable help next quit show
break disable eval info p reload source
catch display exit irb pp restart step
condition down finish list ps save thread
continue edit frame method putl set trace
ruby-debug help v0.10.3
Type 'help
Available commands:
backtrace delete enable help next quit show
break disable eval info p reload source
catch display exit irb pp restart step
condition down finish list ps save thread
continue edit frame method putl set trace
其中比较常用的是next/list/continue/method/backtrace命令。
更多关于ruby-debug,查看以下链接:
http://articles.sitepoint.com/article/debug-rails-app-ruby-debug
http://guides.rubyonrails.org/debugging_rails_applications.html
No comments :
Post a Comment