Have you ever thought about how Rails console was not built for you to read the results of a query that returns more than one object?
So, you are not the only one, and that is why there is a gem called ‘hirb’ that will blow your mind, it will make pretty tables of the query results from your object queries in rails console.
And I’m talking about changing this:
with just one line of code!
But the magic is not mine, it is implemented by the “hirb” gem, and to use it in your rails app, as always, just add the line:
to your Gemfile, after that, every time you want to see tabular data in your rails console, just execute this line before the query:
And if you want to go back to the default, just disable it:
So, as always, the idea of this blog is to help you use the best tool for each job, and when you want to see tabular data in your console, for a quick report or just to analyse some data, ‘hirb’ is the best tool for the job.
Is there anything else that you think your rails console could do and you do not know how? leave a comment and I’ll try to help