Daniel Rikowski Daniel Rikowski - 6 months ago 170
Ruby Question

Is there a print_r or var_dump equivalent in Ruby / Ruby on Rails?

I'm looking for a way to dump the structure of an object, similar to the PHP functions

print_r
and
var_dump
for debugging reasons.

Answer

In views:

include DebugHelper

...your code...

debug(object)

In controllers, models, and other code:

puts YAML::dump(object)

Source

Comments