I don’t know what I’m doing, so lots of times, I am working with a Ruby variable that I don’t know the contents of, and when I try to just output it to my webpage, I just get something like #<Variable:0x123abc1don7kn0w>
– I’ve found these two methods of viewing the variable contents, depending on if it is an object or a hash.
<%# Objects %>
<pre><%= @variable.inspect %></pre>
<%# Hashes/Arrays %>
<pre><%= JSON.pretty_generate(variable) %></pre>
It isn’t always full on “pretty print”, but it gets the job done.