File tree Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -196,15 +196,10 @@ def dispatch(name, request) #:nodoc:
196
196
@_request = request
197
197
@_env = request . env
198
198
@_env [ 'action_controller.instance' ] = self
199
- @_env [ 'action_dispatch.show_detailed_exceptions' ] = show_detailed_exceptions?
200
199
process ( name )
201
200
to_a
202
201
end
203
202
204
- def show_detailed_exceptions?
205
- defined? ( Rails . application ) && Rails . application . config . consider_all_requests_local || request . local?
206
- end
207
-
208
203
def to_a #:nodoc:
209
204
response ? response . to_a : [ status , headers , response_body ]
210
205
end
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ module Rescue
3
3
extend ActiveSupport ::Concern
4
4
include ActiveSupport ::Rescuable
5
5
6
+ included do
7
+ config_accessor :consider_all_requests_local
8
+ self . consider_all_requests_local = false if consider_all_requests_local . nil?
9
+ end
10
+
6
11
def rescue_with_handler ( exception )
7
12
if ( exception . respond_to? ( :original_exception ) &&
8
13
( orig_exception = exception . original_exception ) &&
@@ -12,10 +17,15 @@ def rescue_with_handler(exception)
12
17
super ( exception )
13
18
end
14
19
20
+ def show_detailed_exceptions?
21
+ consider_all_requests_local || request . local?
22
+ end
23
+
15
24
private
16
25
def process_action ( *args )
17
26
super
18
27
rescue Exception => exception
28
+ request . env [ 'action_dispatch.show_detailed_exceptions' ] = show_detailed_exceptions?
19
29
rescue_with_handler ( exception ) || raise ( exception )
20
30
end
21
31
end
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ class Railtie < Rails::Railtie
21
21
paths = app . config . paths
22
22
options = app . config . action_controller
23
23
24
+ options . consider_all_requests_local ||= app . config . consider_all_requests_local
25
+
24
26
options . assets_dir ||= paths [ "public" ] . first
25
27
options . javascripts_dir ||= paths [ "public/javascripts" ] . first
26
28
options . stylesheets_dir ||= paths [ "public/stylesheets" ] . first
Original file line number Diff line number Diff line change 1
1
require 'abstract_unit'
2
2
3
3
module ShowExceptions
4
- class ShowExceptionsController < ActionController ::Metal
4
+ class ShowExceptionsController < ActionController ::Base
5
5
use ActionDispatch ::ShowExceptions
6
6
7
7
def boom
@@ -27,7 +27,7 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
27
27
end
28
28
29
29
test 'show diagnostics from a remote ip when consider_all_requests_local is true' do
30
- Rails . stubs ( :application ) . returns stub ( :config => stub ( :consider_all_requests_local => true ) )
30
+ ShowExceptionsController . any_instance . stubs ( :consider_all_requests_local ) . returns ( true )
31
31
@app = ShowExceptionsController . action ( :boom )
32
32
self . remote_addr = '208.77.188.166'
33
33
get '/'
You can’t perform that action at this time.
0 commit comments