Debugging advice

By far the nicest way to debug a rails app is to write more Tests :slight_smile:

You really should not need to step through your code with a debugger since your test cases should show you where the bug is. Just do in your unit/functional tests what you would otherwise do manually in your debugging UI - compare the real values of variables to what you would expect them to be.

cheers, Jens

Jens Kraemer wrote:

By far the nicest way to debug a rails app is to write more Tests :slight_smile: You really should not need to step through your code with a debugger since your test cases should show you where the bug is. Just do in your unit/functional tests what you would otherwise do manually in your debugging UI - compare the real values of variables to what you would expect them to be.   

I must admit to never have used the debugger for tracking down a bug, I find the stack dump or development log to contain the information required (so far). What I find the debugger great for is just learning how rails works better, nothing like stepping through the code as it runs to see what is happening.

-- Anthony

That is the best piece of advice IMO. Though others have pointed out that debugging is good way to learn the flow etc. the real practical advice is to have a thorough coverage of test cases for the entire application.

Debugging and unit testing are to different methods to achieve more flawless application.

The unit testing can be expressed like snapshot checking. You bring your app in some state, than take a snapshot and compare the snapshot taken with expected one. Debugging is more like flow checking. You start your ride at some point of execution and enjoy, more or less, the way your program is taking you.

Both techniques are required. The unit testing will tell you if your program is on the right state on every checkpoint. Debugger can find the paths that are not covered by unit testing.

Since this is about the IDE, I personally use Eclipse (Europa) with Aptana using rails-debug. Some times it is convenient to debug from console but it's up to you.

End for the closing it is essential to learn to read the log files and to use logging as much as possible since some issues are hard to reproduce.