actionpack 7.0.8.7 → 7.2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +90 -537
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +2 -2
  5. data/lib/abstract_controller/asset_paths.rb +2 -0
  6. data/lib/abstract_controller/base.rb +119 -106
  7. data/lib/abstract_controller/caching/fragments.rb +51 -52
  8. data/lib/abstract_controller/caching.rb +2 -0
  9. data/lib/abstract_controller/callbacks.rb +94 -67
  10. data/lib/abstract_controller/collector.rb +6 -6
  11. data/lib/abstract_controller/deprecator.rb +9 -0
  12. data/lib/abstract_controller/error.rb +2 -0
  13. data/lib/abstract_controller/helpers.rb +121 -91
  14. data/lib/abstract_controller/logger.rb +2 -0
  15. data/lib/abstract_controller/railties/routes_helpers.rb +3 -16
  16. data/lib/abstract_controller/rendering.rb +14 -13
  17. data/lib/abstract_controller/translation.rb +12 -30
  18. data/lib/abstract_controller/url_for.rb +9 -5
  19. data/lib/abstract_controller.rb +8 -0
  20. data/lib/action_controller/api/api_rendering.rb +2 -0
  21. data/lib/action_controller/api.rb +78 -73
  22. data/lib/action_controller/base.rb +199 -141
  23. data/lib/action_controller/caching.rb +16 -11
  24. data/lib/action_controller/deprecator.rb +9 -0
  25. data/lib/action_controller/form_builder.rb +21 -16
  26. data/lib/action_controller/log_subscriber.rb +19 -5
  27. data/lib/action_controller/metal/allow_browser.rb +123 -0
  28. data/lib/action_controller/metal/basic_implicit_render.rb +2 -0
  29. data/lib/action_controller/metal/conditional_get.rb +187 -174
  30. data/lib/action_controller/metal/content_security_policy.rb +26 -25
  31. data/lib/action_controller/metal/cookies.rb +4 -2
  32. data/lib/action_controller/metal/data_streaming.rb +65 -54
  33. data/lib/action_controller/metal/default_headers.rb +6 -2
  34. data/lib/action_controller/metal/etag_with_flash.rb +4 -0
  35. data/lib/action_controller/metal/etag_with_template_digest.rb +18 -14
  36. data/lib/action_controller/metal/exceptions.rb +19 -9
  37. data/lib/action_controller/metal/flash.rb +12 -10
  38. data/lib/action_controller/metal/head.rb +20 -16
  39. data/lib/action_controller/metal/helpers.rb +64 -67
  40. data/lib/action_controller/metal/http_authentication.rb +212 -199
  41. data/lib/action_controller/metal/implicit_render.rb +21 -17
  42. data/lib/action_controller/metal/instrumentation.rb +22 -12
  43. data/lib/action_controller/metal/live.rb +125 -92
  44. data/lib/action_controller/metal/logging.rb +6 -4
  45. data/lib/action_controller/metal/mime_responds.rb +151 -142
  46. data/lib/action_controller/metal/parameter_encoding.rb +34 -32
  47. data/lib/action_controller/metal/params_wrapper.rb +58 -58
  48. data/lib/action_controller/metal/permissions_policy.rb +14 -13
  49. data/lib/action_controller/metal/rate_limiting.rb +62 -0
  50. data/lib/action_controller/metal/redirecting.rb +110 -84
  51. data/lib/action_controller/metal/renderers.rb +50 -49
  52. data/lib/action_controller/metal/rendering.rb +103 -82
  53. data/lib/action_controller/metal/request_forgery_protection.rb +279 -161
  54. data/lib/action_controller/metal/rescue.rb +12 -8
  55. data/lib/action_controller/metal/streaming.rb +174 -132
  56. data/lib/action_controller/metal/strong_parameters.rb +598 -473
  57. data/lib/action_controller/metal/testing.rb +2 -0
  58. data/lib/action_controller/metal/url_for.rb +23 -14
  59. data/lib/action_controller/metal.rb +145 -61
  60. data/lib/action_controller/railtie.rb +25 -9
  61. data/lib/action_controller/railties/helpers.rb +2 -0
  62. data/lib/action_controller/renderer.rb +105 -66
  63. data/lib/action_controller/template_assertions.rb +4 -2
  64. data/lib/action_controller/test_case.rb +157 -128
  65. data/lib/action_controller.rb +17 -3
  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 +28 -29
  69. data/lib/action_dispatch/http/content_disposition.rb +2 -0
  70. data/lib/action_dispatch/http/content_security_policy.rb +48 -45
  71. data/lib/action_dispatch/http/filter_parameters.rb +18 -8
  72. data/lib/action_dispatch/http/filter_redirect.rb +22 -1
  73. data/lib/action_dispatch/http/headers.rb +23 -21
  74. data/lib/action_dispatch/http/mime_negotiation.rb +37 -48
  75. data/lib/action_dispatch/http/mime_type.rb +60 -30
  76. data/lib/action_dispatch/http/mime_types.rb +5 -1
  77. data/lib/action_dispatch/http/parameters.rb +12 -10
  78. data/lib/action_dispatch/http/permissions_policy.rb +32 -27
  79. data/lib/action_dispatch/http/rack_cache.rb +4 -0
  80. data/lib/action_dispatch/http/request.rb +132 -79
  81. data/lib/action_dispatch/http/response.rb +136 -103
  82. data/lib/action_dispatch/http/upload.rb +19 -15
  83. data/lib/action_dispatch/http/url.rb +75 -73
  84. data/lib/action_dispatch/journey/formatter.rb +19 -6
  85. data/lib/action_dispatch/journey/gtg/builder.rb +4 -3
  86. data/lib/action_dispatch/journey/gtg/simulator.rb +2 -0
  87. data/lib/action_dispatch/journey/gtg/transition_table.rb +10 -8
  88. data/lib/action_dispatch/journey/nfa/dot.rb +2 -0
  89. data/lib/action_dispatch/journey/nodes/node.rb +6 -5
  90. data/lib/action_dispatch/journey/parser.rb +4 -3
  91. data/lib/action_dispatch/journey/parser_extras.rb +2 -0
  92. data/lib/action_dispatch/journey/path/pattern.rb +18 -15
  93. data/lib/action_dispatch/journey/route.rb +12 -9
  94. data/lib/action_dispatch/journey/router/utils.rb +16 -15
  95. data/lib/action_dispatch/journey/router.rb +13 -10
  96. data/lib/action_dispatch/journey/routes.rb +6 -4
  97. data/lib/action_dispatch/journey/scanner.rb +4 -2
  98. data/lib/action_dispatch/journey/visitors.rb +2 -0
  99. data/lib/action_dispatch/journey.rb +2 -0
  100. data/lib/action_dispatch/log_subscriber.rb +25 -0
  101. data/lib/action_dispatch/middleware/actionable_exceptions.rb +7 -6
  102. data/lib/action_dispatch/middleware/assume_ssl.rb +27 -0
  103. data/lib/action_dispatch/middleware/callbacks.rb +4 -0
  104. data/lib/action_dispatch/middleware/cookies.rb +192 -194
  105. data/lib/action_dispatch/middleware/debug_exceptions.rb +36 -27
  106. data/lib/action_dispatch/middleware/debug_locks.rb +18 -13
  107. data/lib/action_dispatch/middleware/debug_view.rb +9 -2
  108. data/lib/action_dispatch/middleware/exception_wrapper.rb +181 -27
  109. data/lib/action_dispatch/middleware/executor.rb +9 -1
  110. data/lib/action_dispatch/middleware/flash.rb +65 -46
  111. data/lib/action_dispatch/middleware/host_authorization.rb +22 -17
  112. data/lib/action_dispatch/middleware/public_exceptions.rb +12 -8
  113. data/lib/action_dispatch/middleware/reloader.rb +9 -5
  114. data/lib/action_dispatch/middleware/remote_ip.rb +88 -83
  115. data/lib/action_dispatch/middleware/request_id.rb +15 -8
  116. data/lib/action_dispatch/middleware/server_timing.rb +8 -6
  117. data/lib/action_dispatch/middleware/session/abstract_store.rb +7 -0
  118. data/lib/action_dispatch/middleware/session/cache_store.rb +14 -7
  119. data/lib/action_dispatch/middleware/session/cookie_store.rb +32 -25
  120. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +9 -3
  121. data/lib/action_dispatch/middleware/show_exceptions.rb +42 -28
  122. data/lib/action_dispatch/middleware/ssl.rb +60 -45
  123. data/lib/action_dispatch/middleware/stack.rb +15 -9
  124. data/lib/action_dispatch/middleware/static.rb +40 -34
  125. data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +2 -2
  126. data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +4 -4
  127. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +8 -1
  128. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +7 -7
  129. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +2 -2
  130. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +17 -0
  131. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +16 -12
  132. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +1 -1
  133. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +3 -3
  134. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +4 -4
  135. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -1
  136. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +1 -1
  137. data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +3 -0
  138. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +47 -38
  139. data/lib/action_dispatch/railtie.rb +12 -4
  140. data/lib/action_dispatch/request/session.rb +39 -27
  141. data/lib/action_dispatch/request/utils.rb +10 -3
  142. data/lib/action_dispatch/routing/endpoint.rb +2 -0
  143. data/lib/action_dispatch/routing/inspector.rb +59 -9
  144. data/lib/action_dispatch/routing/mapper.rb +686 -639
  145. data/lib/action_dispatch/routing/polymorphic_routes.rb +70 -61
  146. data/lib/action_dispatch/routing/redirection.rb +52 -38
  147. data/lib/action_dispatch/routing/route_set.rb +106 -62
  148. data/lib/action_dispatch/routing/routes_proxy.rb +16 -19
  149. data/lib/action_dispatch/routing/url_for.rb +131 -122
  150. data/lib/action_dispatch/routing.rb +152 -150
  151. data/lib/action_dispatch/system_test_case.rb +91 -81
  152. data/lib/action_dispatch/system_testing/browser.rb +27 -19
  153. data/lib/action_dispatch/system_testing/driver.rb +16 -22
  154. data/lib/action_dispatch/system_testing/server.rb +2 -0
  155. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +53 -31
  156. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +2 -0
  157. data/lib/action_dispatch/testing/assertion_response.rb +9 -7
  158. data/lib/action_dispatch/testing/assertions/response.rb +36 -26
  159. data/lib/action_dispatch/testing/assertions/routing.rb +203 -95
  160. data/lib/action_dispatch/testing/assertions.rb +5 -1
  161. data/lib/action_dispatch/testing/integration.rb +240 -229
  162. data/lib/action_dispatch/testing/request_encoder.rb +6 -1
  163. data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
  164. data/lib/action_dispatch/testing/test_process.rb +14 -9
  165. data/lib/action_dispatch/testing/test_request.rb +4 -2
  166. data/lib/action_dispatch/testing/test_response.rb +34 -19
  167. data/lib/action_dispatch.rb +52 -21
  168. data/lib/action_pack/gem_version.rb +6 -4
  169. data/lib/action_pack/version.rb +3 -1
  170. data/lib/action_pack.rb +18 -17
  171. metadata +86 -27
@@ -1,88 +1,93 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :markup: markdown
4
+
3
5
  module ActionDispatch
4
6
  module Routing
5
- # In <tt>config/routes.rb</tt> you define URL-to-controller mappings, but the reverse
7
+ # # Action Dispatch Routing UrlFor
8
+ #
9
+ # In `config/routes.rb` you define URL-to-controller mappings, but the reverse
6
10
  # is also possible: a URL can be generated from one of your routing definitions.
7
11
  # URL generation functionality is centralized in this module.
8
12
  #
9
- # See ActionDispatch::Routing for general information about routing and <tt>config/routes.rb</tt>.
13
+ # See ActionDispatch::Routing for general information about routing and
14
+ # `config/routes.rb`.
10
15
  #
11
- # <b>Tip:</b> If you need to generate URLs from your models or some other place,
16
+ # **Tip:** If you need to generate URLs from your models or some other place,
12
17
  # then ActionDispatch::Routing::UrlFor is what you're looking for. Read on for
13
- # an introduction. In general, this module should not be included on its own,
14
- # as it is usually included by +url_helpers+ (as in <tt>Rails.application.routes.url_helpers</tt>).
15
- #
16
- # == URL generation from parameters
17
- #
18
- # As you may know, some functions, such as <tt>ActionController::Base#url_for</tt>
19
- # and ActionView::Helpers::UrlHelper#link_to, can generate URLs given a set
20
- # of parameters. For example, you've probably had the chance to write code
21
- # like this in one of your views:
22
- #
23
- # <%= link_to('Click here', controller: 'users',
24
- # action: 'new', message: 'Welcome!') %>
25
- # # => <a href="/users/new?message=Welcome%21">Click here</a>
26
- #
27
- # +link_to+, and all other functions that require URL generation functionality,
28
- # actually use ActionDispatch::Routing::UrlFor under the hood. And in particular,
29
- # they use the ActionDispatch::Routing::UrlFor#url_for method. One can generate
30
- # the same path as the above example by using the following code:
31
- #
32
- # include ActionDispatch::Routing::UrlFor
33
- # url_for(controller: 'users',
34
- # action: 'new',
35
- # message: 'Welcome!',
36
- # only_path: true)
37
- # # => "/users/new?message=Welcome%21"
38
- #
39
- # Notice the <tt>only_path: true</tt> part. This is because UrlFor has no
40
- # information about the website hostname that your Rails app is serving. So if you
41
- # want to include the hostname as well, then you must also pass the <tt>:host</tt>
42
- # argument:
43
- #
44
- # include UrlFor
45
- # url_for(controller: 'users',
46
- # action: 'new',
47
- # message: 'Welcome!',
48
- # host: 'www.example.com')
49
- # # => "http://www.example.com/users/new?message=Welcome%21"
50
- #
51
- # By default, all controllers and views have access to a special version of +url_for+,
52
- # that already knows what the current hostname is. So if you use +url_for+ in your
53
- # controllers or your views, then you don't need to explicitly pass the <tt>:host</tt>
54
- # argument.
18
+ # an introduction. In general, this module should not be included on its own, as
19
+ # it is usually included by `url_helpers` (as in
20
+ # `Rails.application.routes.url_helpers`).
21
+ #
22
+ # ## URL generation from parameters
23
+ #
24
+ # As you may know, some functions, such as `ActionController::Base#url_for` and
25
+ # ActionView::Helpers::UrlHelper#link_to, can generate URLs given a set of
26
+ # parameters. For example, you've probably had the chance to write code like
27
+ # this in one of your views:
28
+ #
29
+ # <%= link_to('Click here', controller: 'users',
30
+ # action: 'new', message: 'Welcome!') %>
31
+ # # => <a href="/users/new?message=Welcome%21">Click here</a>
32
+ #
33
+ # `link_to`, and all other functions that require URL generation functionality,
34
+ # actually use ActionDispatch::Routing::UrlFor under the hood. And in
35
+ # particular, they use the ActionDispatch::Routing::UrlFor#url_for method. One
36
+ # can generate the same path as the above example by using the following code:
37
+ #
38
+ # include ActionDispatch::Routing::UrlFor
39
+ # url_for(controller: 'users',
40
+ # action: 'new',
41
+ # message: 'Welcome!',
42
+ # only_path: true)
43
+ # # => "/users/new?message=Welcome%21"
44
+ #
45
+ # Notice the `only_path: true` part. This is because UrlFor has no information
46
+ # about the website hostname that your Rails app is serving. So if you want to
47
+ # include the hostname as well, then you must also pass the `:host` argument:
48
+ #
49
+ # include UrlFor
50
+ # url_for(controller: 'users',
51
+ # action: 'new',
52
+ # message: 'Welcome!',
53
+ # host: 'www.example.com')
54
+ # # => "http://www.example.com/users/new?message=Welcome%21"
55
+ #
56
+ # By default, all controllers and views have access to a special version of
57
+ # `url_for`, that already knows what the current hostname is. So if you use
58
+ # `url_for` in your controllers or your views, then you don't need to explicitly
59
+ # pass the `:host` argument.
55
60
  #
56
61
  # For convenience, mailers also include ActionDispatch::Routing::UrlFor. So
57
- # within mailers, you can use url_for. However, mailers cannot access
58
- # incoming web requests in order to derive hostname information, so you have
59
- # to provide the +:host+ option or set the default host using
60
- # +default_url_options+. For more information on url_for in mailers see the
61
- # ActionMailer::Base documentation.
62
+ # within mailers, you can use url_for. However, mailers cannot access incoming
63
+ # web requests in order to derive hostname information, so you have to provide
64
+ # the `:host` option or set the default host using `default_url_options`. For
65
+ # more information on url_for in mailers see the ActionMailer::Base
66
+ # documentation.
62
67
  #
63
- #
64
- # == URL generation for named routes
68
+ # ## URL generation for named routes
65
69
  #
66
70
  # UrlFor also allows one to access methods that have been auto-generated from
67
71
  # named routes. For example, suppose that you have a 'users' resource in your
68
- # <tt>config/routes.rb</tt>:
72
+ # `config/routes.rb`:
69
73
  #
70
- # resources :users
74
+ # resources :users
71
75
  #
72
- # This generates, among other things, the method <tt>users_path</tt>. By default,
73
- # this method is accessible from your controllers, views, and mailers. If you need
74
- # to access this auto-generated method from other places (such as a model), then
75
- # you can do that by including <tt>Rails.application.routes.url_helpers</tt> in your class:
76
+ # This generates, among other things, the method `users_path`. By default, this
77
+ # method is accessible from your controllers, views, and mailers. If you need to
78
+ # access this auto-generated method from other places (such as a model), then
79
+ # you can do that by including `Rails.application.routes.url_helpers` in your
80
+ # class:
76
81
  #
77
- # class User < ActiveRecord::Base
78
- # include Rails.application.routes.url_helpers
82
+ # class User < ActiveRecord::Base
83
+ # include Rails.application.routes.url_helpers
79
84
  #
80
- # def base_uri
81
- # user_path(self)
85
+ # def base_uri
86
+ # user_path(self)
87
+ # end
82
88
  # end
83
- # end
84
89
  #
85
- # User.find(1).base_uri # => "/users/1"
90
+ # User.find(1).base_uri # => "/users/1"
86
91
  #
87
92
  module UrlFor
88
93
  extend ActiveSupport::Concern
@@ -108,64 +113,68 @@ module ActionDispatch
108
113
  super
109
114
  end
110
115
 
111
- # Hook overridden in controller to add request information
112
- # with +default_url_options+. Application logic should not
113
- # go into url_options.
116
+ # Hook overridden in controller to add request information with
117
+ # `default_url_options`. Application logic should not go into url_options.
114
118
  def url_options
115
119
  default_url_options
116
120
  end
117
121
 
118
- # Generate a URL based on the options provided, +default_url_options+, and the
119
- # routes defined in <tt>config/routes.rb</tt>. The following options are supported:
122
+ # Generate a URL based on the options provided, `default_url_options`, and the
123
+ # routes defined in `config/routes.rb`. The following options are supported:
124
+ #
125
+ # * `:only_path` - If true, the relative URL is returned. Defaults to `false`.
126
+ # * `:protocol` - The protocol to connect to. Defaults to `"http"`.
127
+ # * `:host` - Specifies the host the link should be targeted at. If
128
+ # `:only_path` is false, this option must be provided either explicitly, or
129
+ # via `default_url_options`.
130
+ # * `:subdomain` - Specifies the subdomain of the link, using the `tld_length`
131
+ # to split the subdomain from the host. If false, removes all subdomains
132
+ # from the host part of the link.
133
+ # * `:domain` - Specifies the domain of the link, using the `tld_length` to
134
+ # split the domain from the host.
135
+ # * `:tld_length` - Number of labels the TLD id composed of, only used if
136
+ # `:subdomain` or `:domain` are supplied. Defaults to
137
+ # `ActionDispatch::Http::URL.tld_length`, which in turn defaults to 1.
138
+ # * `:port` - Optionally specify the port to connect to.
139
+ # * `:anchor` - An anchor name to be appended to the path.
140
+ # * `:params` - The query parameters to be appended to the path.
141
+ # * `:path_params` - The query parameters that will only be used for the named
142
+ # dynamic segments of path. If unused, they will be discarded.
143
+ # * `:trailing_slash` - If true, adds a trailing slash, as in
144
+ # `"/archive/2009/"`.
145
+ # * `:script_name` - Specifies application path relative to domain root. If
146
+ # provided, prepends application path.
120
147
  #
121
- # * <tt>:only_path</tt> - If true, the relative URL is returned. Defaults to +false+.
122
- # * <tt>:protocol</tt> - The protocol to connect to. Defaults to <tt>"http"</tt>.
123
- # * <tt>:host</tt> - Specifies the host the link should be targeted at.
124
- # If <tt>:only_path</tt> is false, this option must be
125
- # provided either explicitly, or via +default_url_options+.
126
- # * <tt>:subdomain</tt> - Specifies the subdomain of the link, using the +tld_length+
127
- # to split the subdomain from the host.
128
- # If false, removes all subdomains from the host part of the link.
129
- # * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+
130
- # to split the domain from the host.
131
- # * <tt>:tld_length</tt> - Number of labels the TLD id composed of, only used if
132
- # <tt>:subdomain</tt> or <tt>:domain</tt> are supplied. Defaults to
133
- # <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1.
134
- # * <tt>:port</tt> - Optionally specify the port to connect to.
135
- # * <tt>:anchor</tt> - An anchor name to be appended to the path.
136
- # * <tt>:params</tt> - The query parameters to be appended to the path.
137
- # * <tt>:trailing_slash</tt> - If true, adds a trailing slash, as in <tt>"/archive/2009/"</tt>.
138
- # * <tt>:script_name</tt> - Specifies application path relative to domain root. If provided, prepends application path.
139
148
  #
140
- # Any other key (<tt>:controller</tt>, <tt>:action</tt>, etc.) given to
141
- # +url_for+ is forwarded to the Routes module.
149
+ # Any other key (`:controller`, `:action`, etc.) given to `url_for` is forwarded
150
+ # to the Routes module.
142
151
  #
143
- # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', port: '8080'
144
- # # => 'http://somehost.org:8080/tasks/testing'
145
- # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', anchor: 'ok', only_path: true
146
- # # => '/tasks/testing#ok'
147
- # url_for controller: 'tasks', action: 'testing', trailing_slash: true
148
- # # => 'http://somehost.org/tasks/testing/'
149
- # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', number: '33'
150
- # # => 'http://somehost.org/tasks/testing?number=33'
151
- # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', script_name: "/myapp"
152
- # # => 'http://somehost.org/myapp/tasks/testing'
153
- # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', script_name: "/myapp", only_path: true
154
- # # => '/myapp/tasks/testing'
152
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', port: '8080'
153
+ # # => 'http://somehost.org:8080/tasks/testing'
154
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', anchor: 'ok', only_path: true
155
+ # # => '/tasks/testing#ok'
156
+ # url_for controller: 'tasks', action: 'testing', trailing_slash: true
157
+ # # => 'http://somehost.org/tasks/testing/'
158
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', number: '33'
159
+ # # => 'http://somehost.org/tasks/testing?number=33'
160
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', script_name: "/myapp"
161
+ # # => 'http://somehost.org/myapp/tasks/testing'
162
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', script_name: "/myapp", only_path: true
163
+ # # => '/myapp/tasks/testing'
155
164
  #
156
165
  # Missing routes keys may be filled in from the current request's parameters
157
- # (e.g. +:controller+, +:action+, +:id+, and any other parameters that are
158
- # placed in the path). Given that the current action has been reached
159
- # through <tt>GET /users/1</tt>:
166
+ # (e.g. `:controller`, `:action`, `:id`, and any other parameters that are
167
+ # placed in the path). Given that the current action has been reached through
168
+ # `GET /users/1`:
160
169
  #
161
- # url_for(only_path: true) # => '/users/1'
162
- # url_for(only_path: true, action: 'edit') # => '/users/1/edit'
163
- # url_for(only_path: true, action: 'edit', id: 2) # => '/users/2/edit'
170
+ # url_for(only_path: true) # => '/users/1'
171
+ # url_for(only_path: true, action: 'edit') # => '/users/1/edit'
172
+ # url_for(only_path: true, action: 'edit', id: 2) # => '/users/2/edit'
164
173
  #
165
- # Notice that no +:id+ parameter was provided to the first +url_for+ call
166
- # and the helper used the one from the route's path. Any path parameter
167
- # implicitly used by +url_for+ can always be overwritten like shown on the
168
- # last +url_for+ calls.
174
+ # Notice that no `:id` parameter was provided to the first `url_for` call and
175
+ # the helper used the one from the route's path. Any path parameter implicitly
176
+ # used by `url_for` can always be overwritten like shown on the last `url_for`
177
+ # calls.
169
178
  def url_for(options = nil)
170
179
  full_url_for(options)
171
180
  end
@@ -194,21 +203,21 @@ module ActionDispatch
194
203
 
195
204
  # Allows calling direct or regular named route.
196
205
  #
197
- # resources :buckets
206
+ # resources :buckets
198
207
  #
199
- # direct :recordable do |recording|
200
- # route_for(:bucket, recording.bucket)
201
- # end
208
+ # direct :recordable do |recording|
209
+ # route_for(:bucket, recording.bucket)
210
+ # end
202
211
  #
203
- # direct :threadable do |threadable|
204
- # route_for(:recordable, threadable.parent)
205
- # end
212
+ # direct :threadable do |threadable|
213
+ # route_for(:recordable, threadable.parent)
214
+ # end
206
215
  #
207
- # This maintains the context of the original caller on
208
- # whether to return a path or full URL, e.g:
216
+ # This maintains the context of the original caller on whether to return a path
217
+ # or full URL, e.g:
209
218
  #
210
- # threadable_path(threadable) # => "/buckets/1"
211
- # threadable_url(threadable) # => "http://example.com/buckets/1"
219
+ # threadable_path(threadable) # => "/buckets/1"
220
+ # threadable_url(threadable) # => "http://example.com/buckets/1"
212
221
  #
213
222
  def route_for(name, *args)
214
223
  public_send(:"#{name}_url", *args)