Hirb doesn't work at all in rails console

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

I've already done sudo gem install hirb

and added hirb to my Gemfile:

gem 'hirb', '~>0.7.0'

Then I launched bundle install

And I get this result :

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

Could anyone help?


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

require 'hirb'


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

Yoshdog's answer is outdated - it returns an error:

output error: # NoMethodError: undefined method `pager' for nil:NilClass

You can fix this by using the updated code from the docs:

  require 'hirb'
rescue LoadError
  # Missing goodies, bummer

if defined? Hirb
  # Slightly dirty hack to fully support in-session Hirb.disable/enable toggling
  Hirb::View.instance_eval do
    def enable_output_method
      @output_method = true
      @old_print = Pry.config.print
      Pry.config.print = proc do |*args|
        Hirb::View.view_or_page_output(args[1]) || @old_print.call(*args)

    def disable_output_method
      Pry.config.print = @old_print
      @output_method = nil


This will also allow you to enable/disable Hirb, which may come in handy.

Need Your Help

php mysql counter dont work

php mysql count

I made a counter for genres all works fine but there is one problem.

AngularJS: Get data with $http and add it to module's constants

javascript ajax node.js angularjs http

I want to achieve a situtation where once my module is loaded it call the server for some data and than put it in a conatant.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.