Simple debugging in ruby on rails

April 24, 2007 11:37


I often find while writing a ruby on rails applications that i need to display the contents of a variable quickly and easily, this is straight forward in a view, but not so easy in a controller or model. There are a couple of ways to do this:

logger.debug "variable"

will write to the development.log file, or if your using webrick as your development server, you can use:

STDERR.puts "variable"

and it will show up on the console output where your running your server.



Comments

shiningthrough May 10, 2007 11:53

Thanks Josh, yes that is indeed another option, ill add it to the list.

Josh May 08, 2007 19:00

I use breakpoints, they are very powerfull. Check out this: http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint

976ede888dd7df46e366b43d00ac1956f1993b32

type the text from the image