hirb icon indicating copy to clipboard operation
hirb copied to clipboard

Table output not working using Rails 3.2

Open conradwt opened this issue 13 years ago • 7 comments

Hirb doesn't use table output when dealing with ActiveRecord::Base model(s). Next, I have the following within my .irbrc:

Hirb::View.enable
Hirb.enable :output => {"ActiveRecord::Base" => {:class => :auto_table, :options => {:vertical => true}}}
extend Hirb::Console

Next, when I'm in the Rails console and I execute the following things start to work:

Hirb.disable
Hirb.enable

BTW, I have tried the above with .irbrc and no luck.

conradwt avatar Feb 24 '12 10:02 conradwt

Thanks for the report. Patches welcome until I get around to this.

cldwalker avatar Mar 11 '12 15:03 cldwalker

I tried activerecord 3.2.3 and it worked fine. It seems you have a config problem. Try adding an ancestor option:

Hirb.enable :output => {"ActiveRecord::Base" => {:class => :auto_table, :ancestor => true, :options => {:vertical => true}}}

cldwalker avatar Apr 16 '12 12:04 cldwalker

Closing. If you have more to discuss I can reopen.

cldwalker avatar Apr 29 '12 17:04 cldwalker

Hi, I'm still seeing output in the following form when using Rails 3.2.3:

1.9.3p196 :001 > Site.all
Site Load (37.0ms)  SELECT "sites".* FROM "sites" 
[
    [0] #<Site:0x007fd5f0f45560> {
                  :id => 2,
                :name => "Multidão",
               :title => "Produção Cultural Colaborativa",
                :path => "multidao",
                :host => "multidao.localhost",
              :gender => "female",
               :email => "[email protected]",
             :twitter => "multidao_art",
            :facebook => "http://www.facebook.com/pages/Multidaoart/139326962792941",
                :blog => "http://blog.multidao.art.br",
          :created_at => nil,
          :updated_at => nil,
        :auth_gateway => false,
                :port => nil
    },
    [1] #<Site:0x007fd5f46e7180> {
                  :id => 1,
                :name => "Catarse",
               :title => "A primeira plataforma de financiamento colaborativo de projetos criativos do Brasil",
                :path => "catarse",
                :host => "catarse.me",
              :gender => "male",
               :email => "[email protected]",
             :twitter => "Catarse_",
            :facebook => "http://www.facebook.com/Catarse.me",
                :blog => "http://blog.catarse.me",
          :created_at => nil,
          :updated_at => Tue, 06 Sep 2011 18:17:32 PDT -07:00,
        :auth_gateway => false,
                :port => nil
    },
    [2] #<Site:0x007fd5f46ead80> {
                  :id => 3,
                :name => "smartn.me",
               :title => "Produção Cultural Colaborativa",
                :path => "smartn",
                :host => "smartn.me",
              :gender => "female",
               :email => "[email protected]",
             :twitter => "smartnme",
            :facebook => "http://www.facebook.com/pages/SmartNme/161820603885728",
                :blog => "http://blog.smartn.me",
          :created_at => nil,
          :updated_at => Thu, 29 Sep 2011 02:22:36 PDT -07:00,
        :auth_gateway => true,
                :port => nil
    }
]

.irbc:

https://gist.github.com/2569520

conradwt avatar May 01 '12 16:05 conradwt

Strange. If you comment out wirble and awesome_print does hirb work? If you remove the :options key from Hirb.enable, does it work? If not, I need your ruby version and the output of Hirb::View.formatter_config['ActiveRecord::Base']

cldwalker avatar May 01 '12 22:05 cldwalker

I reduced my file, .irbrc down to one line and I'm still not getting the expected output:

require 'rubygems' rescue nil
require 'hirb'

Hirb.enable :output => {"ActiveRecord::Base" => {:class => :auto_table, :ancestor => true, :options => {:vertical => true}}}
1.9.3p196 :001 > Hirb::View.formatter_config['ActiveRecord::Base']
 => {:class=>:auto_table, :ancestor=>true, :options=>{:vertical=>true}} 
$ ruby -v
ruby 1.9.3p196 (2012-04-21 revision 35416) [x86_64-darwin11.3.0]

conradwt avatar May 02 '12 00:05 conradwt

I confirm that is not working with rails 3.2

$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.0]
$ rails -v
Rails 3.2.11
$ bundle exec rails c
Loading development environment (Rails 3.2.11)
[1] pry(main)> Hirb.enable
=> true
[2] pry(main)> Admin.all
  Admin Load (0.3ms)  SELECT "admins".* FROM "admins" 
=> [#<Admin id: 1, email: "[email protected]", encrypted_password: "$2a$10$B9cryaHmz15JsAxCIu31.eZjPGn/P8DuxvfmrPlNUl9....", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2013-02-04 18:05:01", last_sign_in_at: "2013-02-04 18:05:01", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2013-02-04 18:04:32", updated_at: "2013-02-04 18:05:01">]

Update:

I tried another installation with mysql and is working fine, the problem seem to be with postgresql. since I can do the following in the postgre installation

[1] pry(main)> extend Hirb::Console
=> main
[2] pry(main)> table [[:a, :b, :c]], :unicode => true
┌───┬───┬───┐
│ 0 │ 1 │ 2 │
├───┼───┼───┤
│ a ╎ b ╎ c │
└───┴───┴───┘
1 row in set
=> true

asumaran avatar Feb 26 '13 17:02 asumaran