Hirb在rails控制台中根本不工作 [英] Hirb doesn't work at all in rails console

查看:162
本文介绍了Hirb在rails控制台中根本不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循 hirb rdoc 教程,但不幸的是,我的rails控制台根本不工作。

I followed the tutorial on hirb rdoc but unfortunately, my rails console is not working at all.

我已经完成了 sudo gem install hirb

并添加hirb到我的Gemfile:

and added hirb to my Gemfile:

gem 'hirb', '~>0.7.0'

然后我启动了 bundle install

我得到这个结果:

rails c
Loading development environment (Rails 3.2.11)
> require 'hirb'
=> false
> Hirb.enable
=> true
> Municipality.all
Municipality Load (0.8ms)  SELECT "municipalities".* FROM "municipalities" ORDER BY name asc
=> [#<Municipality id: 1, district_id: 6, name: "Ambalamanasy II", created_at: "2013-01-16 12:11:45", updated_at: "2013-01-16 12:11:45">,
...
# doesn't work

推荐答案

如果您使用pry作为您的rails控制台...将其添加到您的.pryrc文件

If your using pry as your rails console... add this in your .pryrc file

require 'hirb'

Hirb.enable

old_print = Pry.config.print
Pry.config.print = proc do |output, value|
  Hirb::View.view_or_page_output(value) || old_print.call(output, value)
end

这篇关于Hirb在rails控制台中根本不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆