6

I get the impression that in practice, debuggers are rarely used for Rails applications. (Likewise for other Ruby apps, as well as Python.)

We can compare this to the usual practice for Java or VisualStudio programmers--they use an interactive debugger in a graphical IDE.

How do people debug Rails applications in practice? I am aware of the variety of debuggers, so no need to mention those, but do serious Rails programmers work without them? If so, why do you choose to do it this way?

It seems to me that console printing has its limits when debugging complex logic.

5 Answers 5

3

Console printing can work in many situations. This especially, if your code comes in small units instead of large blocks.

Another reason why debuggers are less of an issue in the Rails world is TDD. If you cut down your methods in small and testable items, you can write a complete set of tests for them and make sure they work for a given input. For me this eliminated the need for a debugger. Though this may of course depend on the kind of project. Very large or complex projects may demand to use different tools.

2
  • 1
    Yes, I think you are right. Basic three-tier DB-driven apps with minimal business logic can do without debuggers. But heavy-duty complex code needs them.
    – Joshua Fox
    Dec 12, 2011 at 18:48
  • 1
    @JoshuaFox You are making two assumptions: 1. Ruby code is always Rails code 2. "Real code" needs to be complicated. Those are both wrong and especially the second one scares me. You can write code in a TDD manner independently of your language. I started writing Java code in a TDD manner. My time spent debugging plummeted plus my code is a lot more modular. Dec 12, 2011 at 19:19
7

I think your question is a little poor in its presumption; I use an interactive debugger in a graphical IDE (both in Netbeans and RubyMine depending on where I'm working) to debug Rails development.

1
  • I'm guessing Pavling is a good developer ;)
    – Johntron
    Apr 8, 2015 at 21:50
3

Yeah ruby-debug is good, also

Don't forget about IRB especially with gem's like

http://pry.github.com/

or

https://github.com/jberkel/interactive_editor

2

I wrote about 30 pages on debugging techniques, separated out by various levels—from OS-level debugging tools, to logging tools, to log based alerts, to C tools, to browser debugging techniques. I published this as a series of articles called A Comprehensive Guide To Debugging Rails.

0

If a rails app is well written, with fat models covered by tests and slim controllers and views, there's no need for debugger, because most bugs happen in models and can be detected by tests and console.

However, I maintain a couple of legacy rails apps where I use debugger often (ruby-debug gem), because both controllers and views have a lot of action in them and in such case, debugger is the only way to check out specific app state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.