在rails console
下执行查询返回的结果集排版太差,看着就晕,用pp
稍微好点,但还是不完美,不知大家有没有同感。
今天发现这个hirb https://github.com/cldwalker/hirb
还不错,非常类似 mysql 的 console
效果如下:
1.9.3p0 :010 > Tag.all
Tag Load (0.2ms) SELECT "tags".* FROM "tags"
+----+-----------+---------------------------+
| id | name | created_at |
+----+-----------+---------------------------+
| 1 | test | 2012-02-21 21:30:32 +0800 |
| 2 | spring | 2012-02-21 21:30:32 +0800 |
| 3 | hibernate | 2012-02-21 21:30:32 +0800 |
| 4 | cakephp | 2012-02-21 21:30:32 +0800 |
| 5 | rails | 2012-02-21 21:30:32 +0800 |
| 6 | sinatra | 2012-02-21 21:30:32 +0800 |
| 7 | helper | 2012-02-21 21:30:32 +0800 |
| 8 | oo | 2012-02-21 21:30:32 +0800 |
+----+-----------+---------------------------+
8 rows in set
##使用方法:
gem 'hirb'
Hirb.enable