mardi 30 juillet 2019

How to list the attribute names of a rails request object without seeing nested values

When I am debugging the request spec for a particular rails route, I often want to see what response a particular route produced. So, I insert the line binding.pry into my request spec, so that I can look at the response object. However, when I print response to the console, the shell prints the full object and all its recursively nested attributes. This is over 1000 lines long and consequently very hard to read. I would like to see just the top-level attribute names of that object, how can I do so?

Is there a ruby or rails equivalent to python's function dir(some_object)?

Aucun commentaire:

Enregistrer un commentaire