1

I am using Hirb in my Rails console to try to display mongoid records in a nicer looking table, but the _id, created_at, and updated_at fields take too much space and, even though I really have one meaning field, name, when I do a Project.first it returns a rather disintegrated table:

enter image description here

Is there any chance that there's a way to 'ignore' or 'hide' certain fields?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Nik So
  • 16,683
  • 21
  • 74
  • 108

1 Answers1

3

When you open up hirb, run this:

table projects, :fields => [:name]

Then Project.all and enjoy! ;-)

Also see this: Hirb - Irb On The Good Stuff.

UPDATE:

"Hirb also supports a yaml configuration file (config/hirb.yml or ~/.hirb.yml)"

  ---
    :output:
      Project:
        :options:
          :fields:
            - name
Behrang
  • 46,888
  • 25
  • 118
  • 160
  • it works. though I'd prefer not having to type out table ..., :fields => [...] every time I retrieve records. I guess that's the best can be done? – Nik So Aug 24 '11 at 01:50
  • 1
    It is explained in the link in my answer. I'll update the post with that info. – Behrang Aug 24 '11 at 04:05