« Linked | Main | Continuous Integration »

Debugging Rails

Yesterday I was going nuts trying to spot a problem in one of my test cases. The test case had proven it's worth by identifying a problem that I couldn't see through the web (a double redirect to the same page) but then I couldn't work out why it was happening.

Eventually I got fed up and started looking into how to debug Ruby on Rails. I used two techniques to help me out:

* Firstly the good old write a message to the log file. This can be done with logger.info "message".
* Secondly I used the command "breakpoint" which in test mode causes the test suite to drop into a console where local_variables can be used to see exactly that and any other ruby commands can be issued. Very handy.

Comments

I love the expression. Everyone needs to express there own opinion and feel free to hear others. Keep it up :)

Really helpful information for me. Thnak U much times as think as possible. Luv U

Post a comment