Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force a vertical table or limit columns in Hirb?

Tags:

ruby

irb

I want to display few active records in rails console, I have Hirb enabled. The table is narrow enough to be displayed (so Hirb uses standard, horizontal table) but columns are so narrow that content is completely unreadable. Do you have any idea what I could do about it?

Displaying only few columns would be great (I have records in a pure Array, not AR collection, so I cannot just pass :select to finder method). Forcing Hirb to display records in vertical table would be perfect as well.

Thanks in advance.

like image 441
skalee Avatar asked Aug 11 '10 11:08

skalee


1 Answers

If you look at the 'Views: Anytime, Anywhere' section of hirb's readme, you'll see that hirb provides you with a table command that let's you select columns/fields:

>> extend Hirb::Console
=> main
>> table My_AR_Array, :fields=>[:field1, :another_field, :and_another_one]
# ... Displays table with only these three columns

If you'd like to enable a vertical view, read the docs. In particular, learn about a table's options (:vertical is what you want) and learn about hirb's config file format.

In the future, please ask these questions on github.

like image 124
cldwalker Avatar answered Oct 01 '22 20:10

cldwalker