DEV Community

loading...
Cover image for How to simplify reading your Rails console

How to simplify reading your Rails console

Elizabeth Villalejos
["Full-stack web dev", "Chihuahua Mom🐶", "Currently Looking for Dev Role"]
Updated on ・1 min read

Rails console is a great tool when you are experimenting with your code, but if we have a lot of data it can become a bit complicated and time consuming.

Currently I'm working on a chat app and while creating users the output in console became a bit verbose since it's all smashed together.

Today I learned

You can fix this by adding a gem called hirb to your gemfile.

Hirb is a 'mini view framework' that formats output console according to its type. So you go from something like this:

To this:

After installing it, run the rails console command and write Hirb.enable on console.

Tip-on-tip: make sure the H is capital when using console. For adding to gemfile lowercase hirb it's okay.

That's it, you're set.

What did you learn today?

Discussion (2)

Collapse
n8chz profile image
Lorraine Lee • Edited

The table rendering looks very MySQL/MariaDB. Does Hirb work with Sqlite?

Apparently they changed the spelling from Hirb to hirb.

Collapse
misselliev profile image
Elizabeth Villalejos Author

Hi Lorraine! Yes, it works on it. I tested it both on Postgresql and SQLite.

About the capitalizing, it'd be lowercase when adding to Gemfile but when using it in console capital H otherwise it prompts you to see if you're trying to say irb.

Forem Open with the Forem app