Skip to content

Commit

Permalink
Merge pull request #72 from mattbrictson/fix-rails-32
Browse files Browse the repository at this point in the history
Fix Rails 3.2 compatibility by not using `try`
  • Loading branch information
mattbrictson committed May 21, 2016
2 parents 237514e + 597947d commit b67d8b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion lib/xray/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!(/<body[^>]*>/) { "#{$~}\n#{render_xray_bar}" }
end
Expand Down

0 comments on commit b67d8b3

Please sign in to comment.