Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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 '11 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. –  sebastiangeiger Dec 12 '11 at 19:19
add comment

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.

share|improve this answer
    
Thanks, that's good to know. –  Joshua Fox Dec 12 '11 at 13:53
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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