I’ve had this question for a long time, but I’ve not asked it before. When looking at a problem, I sometimes get a massive lump of text, which is a dump of a Ruby/Rails object. It has no new lines and includes nested objects, arrays and much more. Here is a tiny example (separated into lines at each comma):
Agree with Eric. Try pretty print or “pp” in the console. You can also look into using awesome printwhich tends to provide additional formatting and structure to inspect these.
For especially long or nested object operations it can be helpful to use the pluck method to inspect a single attribute or filter method to select a segment of them. Combining these can give you quicker insight into the objects you’re dealing with.
Thanks @Eric_Hayes and @mzagaja,
I have awesome_print, and use it when I can.
It’s when I am not in a console, or using a debugger that the problem arises.
In the current case, I have a stacklevel too deep problem, and I am chasing it in initializers and the route mapper.
Perhaps, I should write a pp for this text dump format myself, but that is not going to move me any further ahead with my current problem (not soon, anyway).
One thing I have relied on in the past is this online formatter: https://codebeautify.org/ruby-formatter-beautifier which not only can do a Ruby object notation (what I think you’re looking at in your case) but also JSON and XML. When I have a one-off lump of text that I need to unspool and make more visually understandable, I will often use that or one of its variants.