I’m having hard time debugging the flow of the code on “Ruby on Rails”. Please give me some tips. I’m new to “Ruby on rails”. Like in php we use var_dump,print_r and die, just to check where the data has reached.
I’m having hard time debugging the flow of the code on Ruby on Rails.
Share
Comparable tricks in Ruby:
Output something to the server log (
log/development.logby default).I usually keep one terminal window watching the log whenever I’m developing. (
tail -f /log/development.log)You can use
putsorlogger.infoto print things into the log, but personally I like this gem, lll, which logs out nicely highlighted versions of whatever you pass it.To stop execution, you can use
abortorraise. E.g.:When you do this in development mode, as with any other exception, Rails renders a page with a bunch of handy stuff on it – the exception, a stack trace, and the current state of parameter, session and environment variables.