brentd / xray-rails

☠️ A development tool that reveals your UI's bones
MIT License
1.22k stars 79 forks source link

0.1.20 breaks backwards compatibility with Rails 3.2 #71

Closed mattbrictson closed 8 years ago

mattbrictson commented 8 years ago

As pointed out by @nnc:


response.header['Content-Length'] = content_length unless response.try(:committed?)

this line raises the error below on Rails 3.2. It seems ActionDispatch::Response#committed? was added in Rails 4.0.

NoMethodError - undefined method `committed?' for #<ActionDispatch::Response:0x007f92c2ecedf0>:
  activesupport (3.2.22.2) lib/active_support/core_ext/object/try.rb:36:in `try'
  xray-rails (0.1.20) lib/xray/middleware.rb:62:in `call'

Just guarding against it with unless response.respond_to?(:committed?) && response.committed? seems to solve this issue for me, but I'm not at all familiar with this code base and don't really know what I'm doing, so can you please take another look at this?

Thanks

mattbrictson commented 8 years ago

It is because the behavior of try has changed. Back in 3.2 it only checked for nil. Nowadays it also checks for respond_to?.

mattbrictson commented 8 years ago

Fixed in xray-rails 0.1.21.