pboling / rack-insight

Debugging toolbar for Rack applications implemented as middleware
http://railsbling.com/retired_projects/rack-insight/
MIT License
151 stars 22 forks source link

rack-insight fails in Sinatra #37

Closed javierhonduco closed 9 years ago

javierhonduco commented 9 years ago

Running rack-insight as a Sinatra middleware yields the following error:

undefined method `present?' for body
file: enable-button.rb location: call line: 16

Wondering if I'm doing something wrong or if it's a bug. Cheers,

pboling commented 9 years ago

Sounds like a bug. If present is a rails ism and it should be removed from the code. I think it is. Oops.

javierhonduco commented 9 years ago

Do you think that unless body.empty? or body.nil? would do the trick?

pboling commented 9 years ago

Should be a very simple PR if you want to try. Otherwise I'll try to get to is. Just grep the code for .present?

pboling commented 9 years ago

@Javier yes!

pboling commented 9 years ago

But you need to check nil first, then check empty, because nil does not respond to empty.

pboling commented 9 years ago

This is now fixed in master HEAD. Will close issue when I push a new release to rubygems.org

pboling commented 9 years ago

Released 0.5.30 with this fix.

jlecour commented 9 years ago

On a Rails 4.2.0 app, I get this :

undefined method `empty?' for #<ActionDispatch::Response::RackBody:0x0000011158e578>

rack-insight (0.5.30) lib/rack/insight/enable-button.rb:16:in `call'

Is it related ?

pboling commented 9 years ago

@jlecour Oh, interesting. I had someone else reporting an empty? bug as well. No, it's not related to this bug. Apparently what worked in Rails 3, and I think 4.0, no longer works in 4.2 in the Middleware. This should be a new issue.