Ruby-on-rails – 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.

Best Solution

The .inspect method of any object should format is correctly for display, just do..

<%= theobject.inspect %>

The .methods method may also be of use:

<%= theobject.methods.inspect %>

It may help to put that in <pre> tags, depending on the data