omg-actionpack 8.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +129 -0
  3. data/MIT-LICENSE +21 -0
  4. data/README.rdoc +57 -0
  5. data/lib/abstract_controller/asset_paths.rb +14 -0
  6. data/lib/abstract_controller/base.rb +299 -0
  7. data/lib/abstract_controller/caching/fragments.rb +149 -0
  8. data/lib/abstract_controller/caching.rb +68 -0
  9. data/lib/abstract_controller/callbacks.rb +265 -0
  10. data/lib/abstract_controller/collector.rb +44 -0
  11. data/lib/abstract_controller/deprecator.rb +9 -0
  12. data/lib/abstract_controller/error.rb +8 -0
  13. data/lib/abstract_controller/helpers.rb +243 -0
  14. data/lib/abstract_controller/logger.rb +16 -0
  15. data/lib/abstract_controller/railties/routes_helpers.rb +25 -0
  16. data/lib/abstract_controller/rendering.rb +126 -0
  17. data/lib/abstract_controller/translation.rb +42 -0
  18. data/lib/abstract_controller/url_for.rb +37 -0
  19. data/lib/abstract_controller.rb +36 -0
  20. data/lib/action_controller/api/api_rendering.rb +18 -0
  21. data/lib/action_controller/api.rb +155 -0
  22. data/lib/action_controller/base.rb +332 -0
  23. data/lib/action_controller/caching.rb +49 -0
  24. data/lib/action_controller/deprecator.rb +9 -0
  25. data/lib/action_controller/form_builder.rb +55 -0
  26. data/lib/action_controller/log_subscriber.rb +96 -0
  27. data/lib/action_controller/metal/allow_browser.rb +123 -0
  28. data/lib/action_controller/metal/basic_implicit_render.rb +17 -0
  29. data/lib/action_controller/metal/conditional_get.rb +341 -0
  30. data/lib/action_controller/metal/content_security_policy.rb +86 -0
  31. data/lib/action_controller/metal/cookies.rb +20 -0
  32. data/lib/action_controller/metal/data_streaming.rb +154 -0
  33. data/lib/action_controller/metal/default_headers.rb +21 -0
  34. data/lib/action_controller/metal/etag_with_flash.rb +22 -0
  35. data/lib/action_controller/metal/etag_with_template_digest.rb +59 -0
  36. data/lib/action_controller/metal/exceptions.rb +106 -0
  37. data/lib/action_controller/metal/flash.rb +67 -0
  38. data/lib/action_controller/metal/head.rb +67 -0
  39. data/lib/action_controller/metal/helpers.rb +129 -0
  40. data/lib/action_controller/metal/http_authentication.rb +565 -0
  41. data/lib/action_controller/metal/implicit_render.rb +67 -0
  42. data/lib/action_controller/metal/instrumentation.rb +120 -0
  43. data/lib/action_controller/metal/live.rb +398 -0
  44. data/lib/action_controller/metal/logging.rb +22 -0
  45. data/lib/action_controller/metal/mime_responds.rb +337 -0
  46. data/lib/action_controller/metal/parameter_encoding.rb +84 -0
  47. data/lib/action_controller/metal/params_wrapper.rb +312 -0
  48. data/lib/action_controller/metal/permissions_policy.rb +38 -0
  49. data/lib/action_controller/metal/rate_limiting.rb +62 -0
  50. data/lib/action_controller/metal/redirecting.rb +251 -0
  51. data/lib/action_controller/metal/renderers.rb +181 -0
  52. data/lib/action_controller/metal/rendering.rb +260 -0
  53. data/lib/action_controller/metal/request_forgery_protection.rb +667 -0
  54. data/lib/action_controller/metal/rescue.rb +33 -0
  55. data/lib/action_controller/metal/streaming.rb +183 -0
  56. data/lib/action_controller/metal/strong_parameters.rb +1546 -0
  57. data/lib/action_controller/metal/testing.rb +25 -0
  58. data/lib/action_controller/metal/url_for.rb +65 -0
  59. data/lib/action_controller/metal.rb +339 -0
  60. data/lib/action_controller/railtie.rb +149 -0
  61. data/lib/action_controller/railties/helpers.rb +26 -0
  62. data/lib/action_controller/renderer.rb +161 -0
  63. data/lib/action_controller/template_assertions.rb +13 -0
  64. data/lib/action_controller/test_case.rb +691 -0
  65. data/lib/action_controller.rb +80 -0
  66. data/lib/action_dispatch/constants.rb +34 -0
  67. data/lib/action_dispatch/deprecator.rb +9 -0
  68. data/lib/action_dispatch/http/cache.rb +249 -0
  69. data/lib/action_dispatch/http/content_disposition.rb +47 -0
  70. data/lib/action_dispatch/http/content_security_policy.rb +365 -0
  71. data/lib/action_dispatch/http/filter_parameters.rb +80 -0
  72. data/lib/action_dispatch/http/filter_redirect.rb +50 -0
  73. data/lib/action_dispatch/http/headers.rb +134 -0
  74. data/lib/action_dispatch/http/mime_negotiation.rb +187 -0
  75. data/lib/action_dispatch/http/mime_type.rb +389 -0
  76. data/lib/action_dispatch/http/mime_types.rb +54 -0
  77. data/lib/action_dispatch/http/parameters.rb +119 -0
  78. data/lib/action_dispatch/http/permissions_policy.rb +189 -0
  79. data/lib/action_dispatch/http/rack_cache.rb +67 -0
  80. data/lib/action_dispatch/http/request.rb +498 -0
  81. data/lib/action_dispatch/http/response.rb +556 -0
  82. data/lib/action_dispatch/http/upload.rb +107 -0
  83. data/lib/action_dispatch/http/url.rb +344 -0
  84. data/lib/action_dispatch/journey/formatter.rb +226 -0
  85. data/lib/action_dispatch/journey/gtg/builder.rb +149 -0
  86. data/lib/action_dispatch/journey/gtg/simulator.rb +50 -0
  87. data/lib/action_dispatch/journey/gtg/transition_table.rb +217 -0
  88. data/lib/action_dispatch/journey/nfa/dot.rb +27 -0
  89. data/lib/action_dispatch/journey/nodes/node.rb +208 -0
  90. data/lib/action_dispatch/journey/parser.rb +103 -0
  91. data/lib/action_dispatch/journey/path/pattern.rb +209 -0
  92. data/lib/action_dispatch/journey/route.rb +189 -0
  93. data/lib/action_dispatch/journey/router/utils.rb +105 -0
  94. data/lib/action_dispatch/journey/router.rb +151 -0
  95. data/lib/action_dispatch/journey/routes.rb +82 -0
  96. data/lib/action_dispatch/journey/scanner.rb +70 -0
  97. data/lib/action_dispatch/journey/visitors.rb +267 -0
  98. data/lib/action_dispatch/journey/visualizer/fsm.css +30 -0
  99. data/lib/action_dispatch/journey/visualizer/fsm.js +159 -0
  100. data/lib/action_dispatch/journey/visualizer/index.html.erb +52 -0
  101. data/lib/action_dispatch/journey.rb +7 -0
  102. data/lib/action_dispatch/log_subscriber.rb +25 -0
  103. data/lib/action_dispatch/middleware/actionable_exceptions.rb +46 -0
  104. data/lib/action_dispatch/middleware/assume_ssl.rb +27 -0
  105. data/lib/action_dispatch/middleware/callbacks.rb +38 -0
  106. data/lib/action_dispatch/middleware/cookies.rb +719 -0
  107. data/lib/action_dispatch/middleware/debug_exceptions.rb +206 -0
  108. data/lib/action_dispatch/middleware/debug_locks.rb +129 -0
  109. data/lib/action_dispatch/middleware/debug_view.rb +73 -0
  110. data/lib/action_dispatch/middleware/exception_wrapper.rb +350 -0
  111. data/lib/action_dispatch/middleware/executor.rb +32 -0
  112. data/lib/action_dispatch/middleware/flash.rb +318 -0
  113. data/lib/action_dispatch/middleware/host_authorization.rb +171 -0
  114. data/lib/action_dispatch/middleware/public_exceptions.rb +64 -0
  115. data/lib/action_dispatch/middleware/reloader.rb +16 -0
  116. data/lib/action_dispatch/middleware/remote_ip.rb +199 -0
  117. data/lib/action_dispatch/middleware/request_id.rb +50 -0
  118. data/lib/action_dispatch/middleware/server_timing.rb +78 -0
  119. data/lib/action_dispatch/middleware/session/abstract_store.rb +112 -0
  120. data/lib/action_dispatch/middleware/session/cache_store.rb +66 -0
  121. data/lib/action_dispatch/middleware/session/cookie_store.rb +129 -0
  122. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +34 -0
  123. data/lib/action_dispatch/middleware/show_exceptions.rb +88 -0
  124. data/lib/action_dispatch/middleware/ssl.rb +180 -0
  125. data/lib/action_dispatch/middleware/stack.rb +194 -0
  126. data/lib/action_dispatch/middleware/static.rb +192 -0
  127. data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +13 -0
  128. data/lib/action_dispatch/middleware/templates/rescues/_actions.text.erb +0 -0
  129. data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +22 -0
  130. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +17 -0
  131. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
  132. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +36 -0
  133. data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
  134. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +62 -0
  135. data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
  136. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +12 -0
  137. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +9 -0
  138. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +35 -0
  139. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
  140. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +24 -0
  141. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +16 -0
  142. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +284 -0
  143. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +23 -0
  144. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb +3 -0
  145. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +11 -0
  146. data/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
  147. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +32 -0
  148. data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
  149. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +20 -0
  150. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +7 -0
  151. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +6 -0
  152. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
  153. data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +19 -0
  154. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +232 -0
  155. data/lib/action_dispatch/railtie.rb +77 -0
  156. data/lib/action_dispatch/request/session.rb +283 -0
  157. data/lib/action_dispatch/request/utils.rb +109 -0
  158. data/lib/action_dispatch/routing/endpoint.rb +19 -0
  159. data/lib/action_dispatch/routing/inspector.rb +323 -0
  160. data/lib/action_dispatch/routing/mapper.rb +2372 -0
  161. data/lib/action_dispatch/routing/polymorphic_routes.rb +363 -0
  162. data/lib/action_dispatch/routing/redirection.rb +218 -0
  163. data/lib/action_dispatch/routing/route_set.rb +958 -0
  164. data/lib/action_dispatch/routing/routes_proxy.rb +66 -0
  165. data/lib/action_dispatch/routing/url_for.rb +244 -0
  166. data/lib/action_dispatch/routing.rb +262 -0
  167. data/lib/action_dispatch/system_test_case.rb +206 -0
  168. data/lib/action_dispatch/system_testing/browser.rb +75 -0
  169. data/lib/action_dispatch/system_testing/driver.rb +85 -0
  170. data/lib/action_dispatch/system_testing/server.rb +33 -0
  171. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +164 -0
  172. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +23 -0
  173. data/lib/action_dispatch/testing/assertion_response.rb +48 -0
  174. data/lib/action_dispatch/testing/assertions/response.rb +114 -0
  175. data/lib/action_dispatch/testing/assertions/routing.rb +343 -0
  176. data/lib/action_dispatch/testing/assertions.rb +25 -0
  177. data/lib/action_dispatch/testing/integration.rb +694 -0
  178. data/lib/action_dispatch/testing/request_encoder.rb +60 -0
  179. data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
  180. data/lib/action_dispatch/testing/test_process.rb +57 -0
  181. data/lib/action_dispatch/testing/test_request.rb +73 -0
  182. data/lib/action_dispatch/testing/test_response.rb +58 -0
  183. data/lib/action_dispatch.rb +147 -0
  184. data/lib/action_pack/gem_version.rb +19 -0
  185. data/lib/action_pack/version.rb +12 -0
  186. data/lib/action_pack.rb +27 -0
  187. metadata +375 -0
@@ -0,0 +1,284 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="turbo-visit-control" content="reload">
7
+ <title>Action Controller: Exception caught</title>
8
+ <style>
9
+ body {
10
+ background-color: #FAFAFA;
11
+ color: #333;
12
+ color-scheme: light dark;
13
+ supported-color-schemes: light dark;
14
+ margin: 0px;
15
+ }
16
+
17
+ body, p, ol, ul, td {
18
+ font-family: helvetica, verdana, arial, sans-serif;
19
+ font-size: 13px;
20
+ line-height: 18px;
21
+ }
22
+
23
+ pre {
24
+ font-size: 11px;
25
+ white-space: pre-wrap;
26
+ }
27
+
28
+ pre.box {
29
+ border: 1px solid #EEE;
30
+ padding: 10px;
31
+ margin: 0px;
32
+ width: 958px;
33
+ }
34
+
35
+ header {
36
+ color: #F0F0F0;
37
+ background: #C00;
38
+ padding: 0.5em 1.5em;
39
+ }
40
+
41
+ h1 {
42
+ overflow-wrap: break-word;
43
+ margin: 0.2em 0;
44
+ line-height: 1.1em;
45
+ font-size: 2em;
46
+ }
47
+
48
+ h2 {
49
+ color: #C00;
50
+ line-height: 25px;
51
+ }
52
+
53
+ code.traces {
54
+ font-size: 11px;
55
+ }
56
+
57
+ .response-heading, .request-heading {
58
+ margin-top: 30px;
59
+ }
60
+
61
+ .exception-message {
62
+ padding: 8px 0;
63
+ }
64
+
65
+ .exception-message .message {
66
+ margin-bottom: 8px;
67
+ line-height: 25px;
68
+ font-size: 1.5em;
69
+ font-weight: bold;
70
+ color: #C00;
71
+ }
72
+
73
+ .details {
74
+ border: 1px solid #D0D0D0;
75
+ border-radius: 4px;
76
+ margin: 1em 0px;
77
+ display: block;
78
+ max-width: 978px;
79
+ }
80
+
81
+ .summary {
82
+ padding: 8px 15px;
83
+ border-bottom: 1px solid #D0D0D0;
84
+ display: block;
85
+ }
86
+
87
+ a.summary {
88
+ color: #F0F0F0;
89
+ text-decoration: none;
90
+ background: #C52F24;
91
+ border-bottom: none;
92
+ }
93
+
94
+ .details pre {
95
+ margin: 5px;
96
+ border: none;
97
+ }
98
+
99
+ #container {
100
+ box-sizing: border-box;
101
+ width: 100%;
102
+ padding: 0 1.5em;
103
+ }
104
+
105
+ .source * {
106
+ margin: 0px;
107
+ padding: 0px;
108
+ }
109
+
110
+ .source {
111
+ border: 1px solid #D9D9D9;
112
+ background: #ECECEC;
113
+ max-width: 978px;
114
+ }
115
+
116
+ .source pre {
117
+ padding: 10px 0px;
118
+ border: none;
119
+ }
120
+
121
+ .source .data {
122
+ font-size: 80%;
123
+ overflow: auto;
124
+ background-color: #FFF;
125
+ }
126
+
127
+ .info {
128
+ padding: 0.5em;
129
+ }
130
+
131
+ .source .data .line_numbers {
132
+ background-color: #ECECEC;
133
+ color: #555;
134
+ padding: 1em .5em;
135
+ border-right: 1px solid #DDD;
136
+ text-align: right;
137
+ }
138
+
139
+ .line {
140
+ padding-left: 10px;
141
+ white-space: pre;
142
+ }
143
+
144
+ .line:hover {
145
+ background-color: #F6F6F6;
146
+ }
147
+
148
+ .line.active {
149
+ background-color: #FCC;
150
+ }
151
+
152
+ .error_highlight {
153
+ display: inline-block;
154
+ background-color: #FF9;
155
+ text-decoration: #F00 wavy underline;
156
+ }
157
+
158
+ .error_highlight_tip {
159
+ color: #666;
160
+ padding: 2px 2px;
161
+ font-size: 10px;
162
+ }
163
+
164
+ .button_to {
165
+ display: inline-block;
166
+ margin-top: 0.75em;
167
+ margin-bottom: 0.75em;
168
+ }
169
+
170
+ .hidden {
171
+ display: none;
172
+ }
173
+
174
+ .correction {
175
+ list-style-type: none;
176
+ }
177
+
178
+ input[type="submit"] {
179
+ color: white;
180
+ background-color: #C00;
181
+ border: none;
182
+ border-radius: 12px;
183
+ box-shadow: 0 3px #F99;
184
+ font-size: 13px;
185
+ font-weight: bold;
186
+ margin: 0;
187
+ padding: 10px 18px;
188
+ cursor: pointer;
189
+ -webkit-appearance: none;
190
+ }
191
+ input[type="submit"]:focus,
192
+ input[type="submit"]:hover {
193
+ opacity: 0.8;
194
+ }
195
+ input[type="submit"]:active {
196
+ box-shadow: 0 2px #F99;
197
+ transform: translateY(1px)
198
+ }
199
+
200
+ a { color: #980905; }
201
+ a:visited { color: #666; }
202
+ a.trace-frames {
203
+ color: #666;
204
+ overflow-wrap: break-word;
205
+ }
206
+ a:hover, a.trace-frames.selected { color: #C00; }
207
+ a.summary:hover { color: #FFF; }
208
+
209
+ @media (prefers-color-scheme: dark) {
210
+ body {
211
+ background-color: #222;
212
+ color: #ECECEC;
213
+ }
214
+
215
+ .details, .summary {
216
+ border-color: #666;
217
+ }
218
+
219
+ .source {
220
+ border-color: #555;
221
+ background-color: #333;
222
+ }
223
+
224
+ .source .data {
225
+ background: #444;
226
+ }
227
+
228
+ .source .data .line_numbers {
229
+ background: #333;
230
+ border-color: #222;
231
+ }
232
+
233
+ .line:hover {
234
+ background: #666;
235
+ }
236
+
237
+ .line.active {
238
+ background-color: #900;
239
+ }
240
+
241
+ .error_highlight {
242
+ color: #333;
243
+ }
244
+
245
+ input[type="submit"] {
246
+ box-shadow: 0 3px #800;
247
+ }
248
+ input[type="submit"]:active {
249
+ box-shadow: 0 2px #800;
250
+ }
251
+
252
+ a { color: #C00; }
253
+ a.trace-frames { color: #999; }
254
+ a:hover, a.trace-frames.selected { color: #E9382B; }
255
+ }
256
+
257
+ <%= yield :style %>
258
+ </style>
259
+
260
+ <script>
261
+ var toggle = function(id) {
262
+ document.getElementById(id).classList.toggle('hidden');
263
+ return false;
264
+ }
265
+ var show = function(id) {
266
+ document.getElementById(id).style.display = 'block';
267
+ }
268
+ var hide = function(id) {
269
+ document.getElementById(id).style.display = 'none';
270
+ }
271
+ var toggleSessionDump = function() {
272
+ return toggle('session_dump');
273
+ }
274
+ var toggleEnvDump = function() {
275
+ return toggle('env_dump');
276
+ }
277
+ </script>
278
+ </head>
279
+ <body>
280
+
281
+ <%= yield %>
282
+
283
+ </body>
284
+ </html>
@@ -0,0 +1,23 @@
1
+ <header role="banner">
2
+ <h1>No view template for interactive request</h1>
3
+ </header>
4
+
5
+ <main id="container">
6
+ <h2><%= h @exception.message %></h2>
7
+
8
+ <div class="summary">
9
+ <p>
10
+ <strong>NOTE:</strong> Rails usually expects a controller action to render a view template with the same name.
11
+ </p>
12
+ <p>
13
+ For example, a <code><%= @exception.controller %>#<%= @exception.action_name %></code> action defined in <code>app/controllers/<%= @exception.controller.controller_path %>_controller.rb</code> should have a corresponding view template
14
+ in a file named <code>app/views/<%= @exception.controller.controller_path %>/<%= @exception.action_name %>.html.erb</code>.
15
+ </p>
16
+ <p>
17
+ However, if this controller is an API endpoint responding with 204 (No Content), which does not require a view template because it doesn't serve an HTML response, then this error will occur when trying to access it with a browser. In this particular scenario, you can ignore this error.
18
+ </p>
19
+ <p>
20
+ You can find more about view template rendering conventions in the <a href="https://guides.rubyonrails.org/layouts_and_rendering.html#rendering-by-default-convention-over-configuration-in-action">Rails Guides on Layouts and Rendering in Rails</a>.
21
+ </p>
22
+ </div>
23
+ </main>
@@ -0,0 +1,3 @@
1
+ Missing exact template
2
+
3
+ <%= @exception.message %>
@@ -0,0 +1,11 @@
1
+ <header role="banner">
2
+ <h1>Template is missing</h1>
3
+ </header>
4
+
5
+ <main role="main" id="container">
6
+ <h2><%= h @exception_wrapper.message %></h2>
7
+
8
+ <%= render "rescues/source", source_extracts: @source_extracts, show_source_idx: @show_source_idx %>
9
+ <%= render "rescues/trace", traces: @traces, trace_to_show: @trace_to_show %>
10
+ <%= render template: "rescues/_request_and_response" %>
11
+ </main>
@@ -0,0 +1,3 @@
1
+ Template is missing
2
+
3
+ <%= @exception.message %>
@@ -0,0 +1,32 @@
1
+ <header role="banner">
2
+ <h1>Routing Error</h1>
3
+ </header>
4
+ <main role="main" id="container">
5
+ <h2><%= h @exception_wrapper.message %></h2>
6
+ <% unless @exception_wrapper.failures.empty? %>
7
+ <p>
8
+ <h2>Failure reasons:</h2>
9
+ <ol>
10
+ <% @exception_wrapper.failures.each do |route, reason| %>
11
+ <li><code><%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %></li>
12
+ <% end %>
13
+ </ol>
14
+ </p>
15
+ <% end %>
16
+
17
+ <%= render "rescues/trace", traces: @traces, trace_to_show: @trace_to_show %>
18
+
19
+ <% if @routes_inspector %>
20
+ <h2>
21
+ Routes
22
+ </h2>
23
+
24
+ <p>
25
+ Routes match in priority from top to bottom
26
+ </p>
27
+
28
+ <%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %>
29
+ <% end %>
30
+
31
+ <%= render template: "rescues/_request_and_response" %>
32
+ </main>
@@ -0,0 +1,11 @@
1
+ Routing Error
2
+
3
+ <%= @exception.message %>
4
+ <% unless @exception.failures.empty? %>
5
+ Failure reasons:
6
+ <% @exception.failures.each do |route, reason| %>
7
+ - <%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %>
8
+ <% end %>
9
+ <% end %>
10
+
11
+ <%= render template: "rescues/_trace", format: :text %>
@@ -0,0 +1,20 @@
1
+ <header role="banner">
2
+ <h1>
3
+ <%= @exception_wrapper.exception_name %> in
4
+ <%= @request.parameters["controller"].camelize if @request.parameters["controller"] %>#<%= @request.parameters["action"] %>
5
+ </h1>
6
+ </header>
7
+
8
+ <main role="main" id="container">
9
+ <p>
10
+ Showing <i><%= @exception_wrapper.file_name %></i> where line <b>#<%= @exception_wrapper.line_number %></b> raised:
11
+ </p>
12
+ <pre><code><%= h @exception_wrapper.message %></code></pre>
13
+
14
+ <%= render "rescues/source", source_extracts: @source_extracts, show_source_idx: @show_source_idx %>
15
+
16
+ <p><%= @exception_wrapper.sub_template_message %></p>
17
+
18
+ <%= render "rescues/trace", traces: @traces, trace_to_show: @trace_to_show %>
19
+ <%= render template: "rescues/_request_and_response" %>
20
+ </main>
@@ -0,0 +1,7 @@
1
+ <%= @exception.cause.class.to_s %> in <%= @request.parameters["controller"].camelize if @request.parameters["controller"] %>#<%= @request.parameters["action"] %>
2
+
3
+ Showing <%= @exception.file_name %> where line #<%= @exception.line_number %> raised:
4
+ <%= @exception.message %>
5
+ <%= @exception.sub_template_message %>
6
+ <%= render template: "rescues/_trace", format: :text %>
7
+ <%= render template: "rescues/_request_and_response", format: :text %>
@@ -0,0 +1,6 @@
1
+ <header role="banner">
2
+ <h1>Unknown action</h1>
3
+ </header>
4
+ <main role="main" id="container">
5
+ <%= render "rescues/message_and_suggestions", exception: @exception, exception_wrapper: @exception_wrapper %>
6
+ </main>
@@ -0,0 +1,3 @@
1
+ Unknown action
2
+
3
+ <%= @exception_wrapper.message %>
@@ -0,0 +1,19 @@
1
+ <tr class='route_row' data-helper='path'>
2
+ <td data-route-name='<%= route[:name] %>'>
3
+ <% if route[:name].present? %>
4
+ <%= route[:name] %><span class='helper'>_path</span>
5
+ <% end %>
6
+ </td>
7
+ <td>
8
+ <%= route[:verb] %>
9
+ </td>
10
+ <td data-route-path='<%= route[:path] %>'>
11
+ <%= route[:path] %>
12
+ </td>
13
+ <td>
14
+ <%=simple_format route[:reqs] %>
15
+ </td>
16
+ <td>
17
+ <%=simple_format route[:source_location] %>
18
+ </td>
19
+ </tr>
@@ -0,0 +1,232 @@
1
+ <% content_for :style do %>
2
+ h2, p {
3
+ padding-left: 30px;
4
+ }
5
+
6
+ #route_table {
7
+ margin: 0;
8
+ border-collapse: collapse;
9
+ word-wrap:break-word;
10
+ table-layout: fixed;
11
+ width:100%;
12
+ }
13
+
14
+ #route_table thead tr {
15
+ border-bottom: 2px solid #ddd;
16
+ }
17
+
18
+ #route_table th {
19
+ padding-left: 30px;
20
+ text-align: left;
21
+ }
22
+
23
+ #route_table thead tr.bottom {
24
+ border-bottom: none;
25
+ }
26
+
27
+ #route_table thead tr.bottom th {
28
+ padding: 10px 30px;
29
+ line-height: 15px;
30
+ }
31
+
32
+ #route_table #search_container {
33
+ padding: 7px 30px;
34
+ }
35
+
36
+ #route_table thead tr th input#search {
37
+ -webkit-appearance: textfield;
38
+ width:100%;
39
+ }
40
+
41
+ #route_table thead th.http-verb {
42
+ width: 10%;
43
+ }
44
+
45
+ #route_table tbody tr {
46
+ border-bottom: 1px solid #ddd;
47
+ }
48
+
49
+ #route_table tbody tr:nth-child(odd) {
50
+ background: #f2f2f2;
51
+ }
52
+
53
+ #route_table tbody.exact_matches,
54
+ #route_table tbody.fuzzy_matches {
55
+ background-color: LightGoldenRodYellow;
56
+ border-bottom: solid 2px SlateGrey;
57
+ }
58
+
59
+ #route_table tbody.exact_matches tr,
60
+ #route_table tbody.fuzzy_matches tr {
61
+ background: none;
62
+ border-bottom: none;
63
+ }
64
+
65
+ #route_table td {
66
+ padding: 4px 30px;
67
+ }
68
+
69
+ @media (prefers-color-scheme: dark) {
70
+ #route_table tbody tr:nth-child(odd) {
71
+ background: #282828;
72
+ }
73
+
74
+ #route_table tbody.exact_matches tr,
75
+ #route_table tbody.fuzzy_matches tr {
76
+ background: DarkSlateGrey;
77
+ }
78
+ }
79
+ <% end %>
80
+
81
+ <table id='route_table'>
82
+ <thead>
83
+ <tr>
84
+ <th>Helper
85
+ (<%= link_to "Path", "#", 'data-route-helper' => '_path',
86
+ title: "Returns a relative path (without the http or domain)" %> /
87
+ <%= link_to "Url", "#", 'data-route-helper' => '_url',
88
+ title: "Returns an absolute URL (with the http and domain)" %>)
89
+ </th>
90
+ <th class="http-verb">HTTP Verb</th>
91
+ <th>Path</th>
92
+ <th>Controller#Action</th>
93
+ <th>Source Location</th>
94
+ </tr>
95
+ <tr>
96
+ <th colspan="5" id="search_container"><%= search_field(:query, nil, id: 'search', placeholder: "Search") %></th>
97
+ </tr>
98
+ </thead>
99
+ <tbody class='exact_matches' id='exact_matches'>
100
+ </tbody>
101
+ <tbody class='fuzzy_matches' id='fuzzy_matches'>
102
+ </tbody>
103
+ <tbody>
104
+ <%= yield %>
105
+ </tbody>
106
+ </table>
107
+
108
+ <script>
109
+ // support forEach iterator on NodeList
110
+ NodeList.prototype.forEach = Array.prototype.forEach;
111
+
112
+ // Enables query search functionality
113
+ function setupMatchingRoutes() {
114
+ // Check if there are any matched results in a section
115
+ function checkNoMatch(section, trElement) {
116
+ if (section.children.length <= 1) {
117
+ section.appendChild(trElement);
118
+ }
119
+ }
120
+
121
+ // get JSON from URL and invoke callback with result
122
+ function getJSON(url, success) {
123
+ var xhr = new XMLHttpRequest();
124
+ xhr.open('GET', url);
125
+ xhr.onload = function() {
126
+ if (this.status == 200)
127
+ success(JSON.parse(this.response));
128
+ };
129
+ xhr.send();
130
+ }
131
+
132
+ function delayedKeyup(input, callback) {
133
+ var timeout;
134
+ input.onkeyup = function(){
135
+ if (timeout) clearTimeout(timeout);
136
+ timeout = setTimeout(callback, 300);
137
+ }
138
+ }
139
+
140
+ // remove params or fragments
141
+ function sanitizeQuery(query) {
142
+ return query.replace(/[#?].*/, '');
143
+ }
144
+
145
+ var pathElements = document.querySelectorAll('#route_table [data-route-path]'),
146
+ searchElem = document.querySelector('#search'),
147
+ exactSection = document.querySelector('#exact_matches'),
148
+ fuzzySection = document.querySelector('#fuzzy_matches');
149
+
150
+ // Remove matches when no search value is present
151
+ searchElem.onblur = function(e) {
152
+ if (searchElem.value === "") {
153
+ exactSection.innerHTML = "";
154
+ fuzzySection.innerHTML = "";
155
+ }
156
+ }
157
+
158
+ function buildTr(string) {
159
+ var tr = document.createElement('tr');
160
+ var th = document.createElement('th');
161
+ th.setAttribute('colspan', 5);
162
+ tr.appendChild(th);
163
+ th.innerText = string;
164
+ return tr;
165
+ }
166
+
167
+ // On key press perform a search for matching paths
168
+ delayedKeyup(searchElem, function() {
169
+ var query = sanitizeQuery(searchElem.value),
170
+ defaultExactMatch = buildTr("Routes matching '" + query + "':"),
171
+ defaultFuzzyMatch = buildTr("Routes containing '" + query + "':"),
172
+ noExactMatch = buildTr('No exact matches found'),
173
+ noFuzzyMatch = buildTr('No fuzzy matches found');
174
+
175
+ if (!query)
176
+ return searchElem.onblur();
177
+
178
+ getJSON('/rails/info/routes?query=' + query, function(matches){
179
+ // Clear out results section
180
+ exactSection.replaceChildren(defaultExactMatch);
181
+ fuzzySection.replaceChildren(defaultFuzzyMatch);
182
+
183
+ // Display exact matches and fuzzy matches
184
+ pathElements.forEach(function(elem) {
185
+ var elemPath = elem.getAttribute('data-route-path');
186
+ if (matches['exact'].indexOf(elemPath) != -1)
187
+ exactSection.appendChild(elem.parentNode.cloneNode(true));
188
+
189
+ if (matches['fuzzy'].indexOf(elemPath) != -1)
190
+ fuzzySection.appendChild(elem.parentNode.cloneNode(true));
191
+ })
192
+
193
+ // Display 'No Matches' message when no matches are found
194
+ checkNoMatch(exactSection, noExactMatch);
195
+ checkNoMatch(fuzzySection, noFuzzyMatch);
196
+ })
197
+ })
198
+ }
199
+
200
+ // Enables functionality to toggle between `_path` and `_url` helper suffixes
201
+ function setupRouteToggleHelperLinks() {
202
+
203
+ // Sets content for each element
204
+ function setValOn(elems, val) {
205
+ elems.forEach(function(elem) {
206
+ elem.innerHTML = val;
207
+ });
208
+ }
209
+
210
+ // Sets onClick event for each element
211
+ function onClick(elems, func) {
212
+ elems.forEach(function(elem) {
213
+ elem.onclick = func;
214
+ });
215
+ }
216
+
217
+ var toggleLinks = document.querySelectorAll('#route_table [data-route-helper]');
218
+
219
+ onClick(toggleLinks, function(){
220
+ var helperTxt = this.getAttribute("data-route-helper"),
221
+ helperElems = document.querySelectorAll('[data-route-name] span.helper');
222
+
223
+ setValOn(helperElems, helperTxt);
224
+ });
225
+ }
226
+
227
+ setupMatchingRoutes();
228
+ setupRouteToggleHelperLinks();
229
+
230
+ // Focus the search input after page has loaded
231
+ document.getElementById('search').focus();
232
+ </script>