如何调试 Rails 宝石?刚刚发现了 ruby-debug 的美妙,真的很兴奋,但是我想单步执行 action_controller 中的路由代码,但是此时没有设置调试器,似乎只是跳过了我的“调试器” " 例如在 action_controller/routing/route_set.rb 中调用。
我错过了什么?
如何调试 Rails 宝石?刚刚发现了 ruby-debug 的美妙,真的很兴奋,但是我想单步执行 action_controller 中的路由代码,但是此时没有设置调试器,似乎只是跳过了我的“调试器” " 例如在 action_controller/routing/route_set.rb 中调用。
我错过了什么?
我刚刚用 Rails 2.3.4 测试了这个。我在 vendor/rails/actionpack/lib/action_controller/routing/route_set.rb 中的调用方法中添加了一个“调试器”行,运行“rdebug script/server”,浏览到一个页面,它停在正确的行。
您还可以使用类/方法断点;您需要逐步完成应用程序的前几行,直到通过 require 'action_controller' 行,然后输入:b ActionController::Routing::RouteSet.call
。
或者您可以尝试根据文件名和行号设置断点。