How to debug a plugin / gem? (with useful notes to setup and use ruby-debug gem)
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
精彩评论