diff --git a/CHANGELOG.md b/CHANGELOG.md index 311496a..ea1860f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ lesser changes or bug fixes. ## [Unreleased][] * Your contribution here! +* Fix a regression in 0.1.20 that broke Rails 3.2 apps + [#72](https://github.com/brentd/xray-rails/pull/72) ## [0.1.20][] (2016-05-18) diff --git a/lib/xray/middleware.rb b/lib/xray/middleware.rb index 098ab39..01eec24 100644 --- a/lib/xray/middleware.rb +++ b/lib/xray/middleware.rb @@ -59,7 +59,7 @@ def call(env) # Modifying the original response obj maintains compatibility with other middlewares if ActionDispatch::Response === response response.body = [body] - response.header['Content-Length'] = content_length unless response.try(:committed?) + response.header['Content-Length'] = content_length unless committed?(response) response.to_a else headers['Content-Length'] = content_length @@ -73,6 +73,10 @@ def call(env) private + def committed?(response) + response.respond_to?(:committed?) && response.committed? + end + def inject_xray_bar!(html) html.sub!(/]*>/) { "#{$~}\n#{render_xray_bar}" } end