如何调试插件/宝石? (有用的注释来设置和使用ruby-debug gem) [英] How to debug a plugin / gem? (with useful notes to setup and use ruby-debug gem)

查看:142
本文介绍了如何调试插件/宝石? (有用的注释来设置和使用ruby-debug gem)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有像我们如何用logger.debug调试模型/控制器的方法?或甚至更好的方法?

谢谢!

编辑1 p>

使用 ruby​​-debug 对我来说似乎是一个陡峭的学习曲线,任何人都可以指向类似于logger.debug的东西,也许?

编辑2



好的,我想我已经开始了解ruby-debug。



一些有用的新手注意事项设置&使用ruby-debug:

lockquote

  gem install ruby​​-debug $ b $ config / environments / development.rb添加

include'ruby-debug'

 然后在要调试的代码上面添加:

调试器

如果您需要调试第三方插件/ gem,使用

包括'ruby-debug'
调试器

只需使用ruby脚本/服务器运行,不需要添加--debugger


编辑3



这个插件真的帮助我理解Rails应用程序的流程。我强烈建议这对任何新手都要亲!



只需设置ruby-debug,然后在您的应用程序请求的操作下将调试器代码放在控制器中的任何位置。你会发现很好的启示!

解决方案

我强烈建议你学会使用 ruby​​-debug 。您可以通过执行以下操作来安装它:

  gem install ruby​​-debug 

然后,您可以在插件代码或您的代码调用插件的位置向代码中添加调试器语句,看看发生了什么问题。



我也亲自使用这些设置,使它更容易使用 - 将它们放在〜/ .rdebugrc 文件。

  set autoeval 
set autolist
设置自动加载


Is there a way like how we debug models / controllers with logger.debug? Or even a better method?

Thank you!

Edit 1

Using ruby-debug seems like a steep learning curve for me, could anyone point me something similar to logger.debug, perhaps?

Edit 2

Alright, I think I started to get a grasp on ruby-debug.

Some useful notes for newbies to setup & use ruby-debug:

gem install ruby-debug
in config/environments/development.rb add

include 'ruby-debug'

then just above the code you want to debug add:

debugger

if you need to debug third party plugin / gem, use

include 'ruby-debug'
debugger

just use ruby script/server to run, no need to add --debugger

Edit 3

This plugin really helps me out in understanding the flow of Rails application. I highly recommend this to any newbies going pro!

Simply setup ruby-debug, then put debugger code anywhere in your controller under the action your application requested. You will then find great revelation!

解决方案

I highly recommend you learn to use ruby-debug. You can install it by doing:

gem install ruby-debug

You can then add a debugger statement to your code either in the plugin code or where your code calls the plugin, step through it, and see what's going wrong.

I also personally use these settings which makes it a bit easier to use - put them in a ~/.rdebugrc file.

set autoeval
set autolist
set autoreload

这篇关于如何调试插件/宝石? (有用的注释来设置和使用ruby-debug gem)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆