lib/xray/middleware.rb in xray-rails-0.1.13 vs lib/xray/middleware.rb in xray-rails-0.1.14

- old
+ new

@@ -35,11 +35,11 @@ # Inject xray.js and friends if this is a successful HTML response else status, headers, response = @app.call(env) if html_headers?(status, headers) && body = response_body(response) - body = body.sub(/<body[^>]*>/) { "#{$~}\n#{xray_bar}" } + body = body.sub(/<body[^>]*>/) { "#{$~}\n#{xray_bar(response)}" } # Inject js script tags if assets are unbundled if Rails.application.config.assets.debug append_js!(body, 'jquery', 'xray') append_js!(body, 'backbone', 'xray-backbone') end @@ -59,11 +59,13 @@ end end private - def xray_bar - ActionController::Base.new.render_to_string(:partial => '/xray_bar').html_safe + def xray_bar(response) + ac = ActionController::Base.new + ac.request = response.request if response.respond_to?(:request) + ac.render_to_string(:partial => '/xray_bar').html_safe end # Appends the given `script_name` after the `after_script_name`. def append_js!(html, after_script_name, script_name) # Matches: