简体   繁体   English

如何为Ruby on Rails应用程序启用跟踪

[英]How to enable Trace for a Ruby on Rails application

Is there a capability to enable some type of system trace once in a method in a Ruby on Rails Controller Class? 是否可以在Ruby on Rails控制器类的方法中一次启用某种类型的系统跟踪? Having real difficulty locating the source code getting executed. 很难找到要执行的源代码。

Best thing is to use the ruby debugger. 最好的办法是使用ruby调试器。

Assuming you're using Ruby 1.9.3 (please respond if you're not), you imply do the following: 假设您使用的是Ruby 1.9.3(如果未使用,请回答),这意味着您需要执行以下操作:

  • In your Gemfile, include the following gem 'debugger' 在您的Gemfile中,包括以下gem'debugger gem 'debugger'
  • Run bundle after saving 保存后运行bundle
  • In your controller (or wherever you want to use it) place line debugger where you want code execution to stop. 在控制器中(或您想使用它的任何地方),在要停止执行代码的位置放置行debugger

Not hit your app through the browser and look into where you started the server and you should see the debug prompt. 请勿通过浏览器访问您的应用,并查看启动服务器的位置,您应该会看到调试提示。

You may have to start your server in debug mode, which you do as follows: 您可能必须以调试模式启动服务器,该操作如下:

rails server --debugger

For a lot more information on this and other debugging steps, check out the great Rails Guide - Debugging Rails Applications It's a great introduction to debugging rails apps. 有关此步骤和其他调试步骤的更多信息,请查看出色的Rails指南-调试Rails应用程序这是调试Rails应用程序的重要介绍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM