Help us understand the problem. What is going on with this article?

Rails Console上で出力を整形してくれるHirbが便利

More than 3 years have passed since last update.

以下はRails Console上でusersテーブルから1件だけ取得するクエリだが、結果が少々見づらい。

irb(main):001:0> User.first
  User Load (0.3ms)  SELECT  `users`.* FROM `users`  ORDER BY `users`.`id` ASC LIMIT 1
=> #<User id: 1, status: "active", lock_version: 0, created_at: "2015-08-03 10:25:35 +0900", updated_at: "2015-08-03 10:25:35 +0900">
irb(main):002:0>

そこで、出力結果を整形してくれるHirbというgemを導入してみる。

インストール

Gemfileに以下を記述。

gem 'hirb'
gem 'hirb-unicode'

bundle installを実行。

$ bundle install

Hirbを有効にして、先程と同じクエリを実行してみる。
Rails Console上で以下を実行。

irb(main):002:0> Hirb.enable
=> true
irb(main):003:0> User.first
  User Load (0.3ms)  SELECT  `users`.* FROM `users`  ORDER BY `users`.`id` ASC LIMIT 1
+----+--------+--------------+---------------------------+---------------------------+
| id | status | lock_version | created_at                | updated_at                |
+----+--------+--------------+---------------------------+---------------------------+
| 1  | active | 0            | 2015-08-03 10:25:35 +0900 | 2015-08-03 10:25:35 +0900 |
+----+--------+--------------+---------------------------+---------------------------+
1 row in set
irb(main):004:0>

見やすい。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away