Ruby开发:ActiveRecord与调试技巧全解析
1. 调试技巧
1.1 调试命令
在调试过程中,使用 next 命令可以执行第6/7行代码,并移动到第8行(尚未解释)。 list 命令会再次显示当前所在的位置。此时,你可以尝试评估 @articles 变量:
(rdb:5) @articles
[#<Article id: 4, title: “Oh hi!”, body: “Hi there!\r\n\r\nIf don’t know what %{color:red}Rails% ...”, published: true, published_at: “2008-07-20 03:52:00”, created_at: “2008-07-16 22:56:33”, updated_at: “2008-07-17 16:21:48”>]
除了 list 和 next 命令外, step 、 up 和 cont 也是重要的调试命令。 step 和 up 大致相当于Visual Studio中的F11和Shift + F11。使用 exit 命令可以退出 rdb 调试器。
超级会员免费看
订阅专栏 解锁全文
21

被折叠的 条评论
为什么被折叠?



