Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table output not working using Rails 3.2 #54

Open
conradwt opened this issue Feb 24, 2012 · 7 comments
Open

Table output not working using Rails 3.2 #54

conradwt opened this issue Feb 24, 2012 · 7 comments
Labels

Comments

@conradwt
Copy link

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.

@cldwalker
Copy link
Owner

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

@cldwalker
Copy link
Owner

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
Copy link
Owner

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

@conradwt
Copy link
Author

conradwt commented May 1, 2012

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 => "contato@multidao.art.br",
             :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 => "contato@catarse.me",
             :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 => "contact@smartn.me",
             :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

@cldwalker cldwalker reopened this May 1, 2012
@cldwalker
Copy link
Owner

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']

@conradwt
Copy link
Author

conradwt commented May 2, 2012

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]

@asumaran
Copy link

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: "admin@local.com", 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants