lib/xray/middleware.rb in xray-rails-0.1.19 vs lib/xray/middleware.rb in xray-rails-0.1.20
- old
+ new
@@ -57,11 +57,11 @@
end
# Modifying the original response obj maintains compatibility with other middlewares
if ActionDispatch::Response === response
response.body = [body]
- response.header['Content-Length'] = content_length
+ response.header['Content-Length'] = content_length unless response.try(:committed?)
response.to_a
else
headers['Content-Length'] = content_length
[status, headers, [body]]
end
@@ -76,11 +76,17 @@
def inject_xray_bar!(html)
html.sub!(/<body[^>]*>/) { "#{$~}\n#{render_xray_bar}" }
end
def render_xray_bar
- ac = ActionController::Base.new
- ac.render_to_string(:partial => '/xray_bar').html_safe
+ if ApplicationController.respond_to?(:render)
+ # Rails 5
+ ApplicationController.render(:partial => "/xray_bar").html_safe
+ else
+ # Rails <= 4.2
+ ac = ActionController::Base.new
+ ac.render_to_string(:partial => '/xray_bar').html_safe
+ end
end
# Matches:
# <script src="/assets/jquery.js"></script>
# <script src="/assets/jquery-min.js"></script>