awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.07k stars 454 forks source link

Rails 4.2 Colorize Crash #192

Closed CyborgMaster closed 9 years ago

CyborgMaster commented 9 years ago

When I print out ActiveRecord objects in Rails 4.2. I get the following error:

TypeError:         TypeError: no implicit conversion of Hash into String
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/colored-1.2/lib/colored.rb:70:in `colorize'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/colorize-0.7.5/lib/colorize/class_methods.rb:75:in `block (2 levels) in color_methods'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/formatter.rb:54:in `colorize'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/formatter.rb:85:in `block in awesome_array'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/formatter.rb:83:in `each'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/formatter.rb:83:in `inject'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/formatter.rb:83:in `awesome_array'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/formatter.rb:26:in `format'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/inspector.rb:137:in `unnested'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/inspector.rb:104:in `awesome'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/core_ext/kernel.rb:10:in `ai'
            /Users/jeremy/.rvm/gems/ruby-2.0.0-p451@allynova/gems/awesome_print-1.6.1/lib/awesome_print/core_ext/kernel.rb:20:in `ap'

I think this is an awesome print problem. Sorry if it is in another gem.

CyborgMaster commented 9 years ago

It also seems to happen if I ap an integer like ap 2 weird.

maurogeorge commented 9 years ago

@CyborgMaster what version of Awesome Print you are using.

CyborgMaster commented 9 years ago

1.6.1 (as it shows in the stack trace), which is the latest I believe

maurogeorge commented 9 years ago

@CyborgMaster it is possible to you try awesome_print on a new app, maybe is because some conflict with another gem.

I am using 1.6.1 on a Rails 4.2 project and it is look good to me.

CyborgMaster commented 9 years ago

@maurogeorge, sure I'll try that. I'll try and do it tomorrow, because I'm swamped today.

I think it might have something to do with a conflict with either the colored, or the colorize gem, which awesome print seems to be using here.

maurogeorge commented 9 years ago

@CyborgMaster thanks! Waiting for your feedback :heart:

CyborgMaster commented 9 years ago

So it looks like this is actually a conflict between the colorize and colored gems.

I had the gem capybara-screenshot in my project which depends on colored. Updating to the latest version of capybara-screenshot removed the dependency on colored and fixed the problem.

So turns out it had nothing to do with aweomse_print, it just happened to manifest itself whenever I used the ap command. Sorry for posting the bug report to the wrong project.

Closing.

maurogeorge commented 9 years ago

@CyborgMaster thanks for your feedback, no problem man :smiley: