actionpack 7.1.3 → 7.2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +82 -501
- data/lib/abstract_controller/asset_paths.rb +2 -0
- data/lib/abstract_controller/base.rb +102 -98
- data/lib/abstract_controller/caching/fragments.rb +50 -53
- data/lib/abstract_controller/caching.rb +2 -0
- data/lib/abstract_controller/callbacks.rb +66 -64
- data/lib/abstract_controller/collector.rb +6 -6
- data/lib/abstract_controller/deprecator.rb +2 -0
- data/lib/abstract_controller/error.rb +2 -0
- data/lib/abstract_controller/helpers.rb +70 -85
- data/lib/abstract_controller/logger.rb +2 -0
- data/lib/abstract_controller/railties/routes_helpers.rb +2 -0
- data/lib/abstract_controller/rendering.rb +13 -12
- data/lib/abstract_controller/translation.rb +15 -7
- data/lib/abstract_controller/url_for.rb +8 -6
- data/lib/abstract_controller.rb +2 -0
- data/lib/action_controller/api/api_rendering.rb +2 -0
- data/lib/action_controller/api.rb +74 -72
- data/lib/action_controller/base.rb +198 -126
- data/lib/action_controller/caching.rb +15 -12
- data/lib/action_controller/deprecator.rb +2 -0
- data/lib/action_controller/form_builder.rb +20 -17
- data/lib/action_controller/log_subscriber.rb +3 -1
- data/lib/action_controller/metal/allow_browser.rb +123 -0
- data/lib/action_controller/metal/basic_implicit_render.rb +2 -0
- data/lib/action_controller/metal/conditional_get.rb +188 -174
- data/lib/action_controller/metal/content_security_policy.rb +25 -24
- data/lib/action_controller/metal/cookies.rb +4 -2
- data/lib/action_controller/metal/data_streaming.rb +64 -55
- data/lib/action_controller/metal/default_headers.rb +5 -3
- data/lib/action_controller/metal/etag_with_flash.rb +3 -1
- data/lib/action_controller/metal/etag_with_template_digest.rb +17 -15
- data/lib/action_controller/metal/exceptions.rb +11 -9
- data/lib/action_controller/metal/flash.rb +12 -10
- data/lib/action_controller/metal/head.rb +12 -10
- data/lib/action_controller/metal/helpers.rb +63 -55
- data/lib/action_controller/metal/http_authentication.rb +210 -205
- data/lib/action_controller/metal/implicit_render.rb +17 -15
- data/lib/action_controller/metal/instrumentation.rb +15 -12
- data/lib/action_controller/metal/live.rb +113 -107
- data/lib/action_controller/metal/logging.rb +6 -4
- data/lib/action_controller/metal/mime_responds.rb +151 -142
- data/lib/action_controller/metal/parameter_encoding.rb +34 -32
- data/lib/action_controller/metal/params_wrapper.rb +57 -59
- data/lib/action_controller/metal/permissions_policy.rb +13 -12
- data/lib/action_controller/metal/rate_limiting.rb +62 -0
- data/lib/action_controller/metal/redirecting.rb +108 -82
- data/lib/action_controller/metal/renderers.rb +50 -49
- data/lib/action_controller/metal/rendering.rb +103 -75
- data/lib/action_controller/metal/request_forgery_protection.rb +162 -133
- data/lib/action_controller/metal/rescue.rb +11 -9
- data/lib/action_controller/metal/streaming.rb +138 -136
- data/lib/action_controller/metal/strong_parameters.rb +525 -480
- data/lib/action_controller/metal/testing.rb +2 -0
- data/lib/action_controller/metal/url_for.rb +17 -15
- data/lib/action_controller/metal.rb +86 -60
- data/lib/action_controller/railtie.rb +3 -0
- data/lib/action_controller/railties/helpers.rb +2 -0
- data/lib/action_controller/renderer.rb +42 -36
- data/lib/action_controller/template_assertions.rb +4 -2
- data/lib/action_controller/test_case.rb +146 -126
- data/lib/action_controller.rb +10 -3
- data/lib/action_dispatch/constants.rb +2 -0
- data/lib/action_dispatch/deprecator.rb +2 -0
- data/lib/action_dispatch/http/cache.rb +27 -26
- data/lib/action_dispatch/http/content_disposition.rb +2 -0
- data/lib/action_dispatch/http/content_security_policy.rb +44 -38
- data/lib/action_dispatch/http/filter_parameters.rb +18 -9
- data/lib/action_dispatch/http/filter_redirect.rb +22 -1
- data/lib/action_dispatch/http/headers.rb +22 -22
- data/lib/action_dispatch/http/mime_negotiation.rb +30 -41
- data/lib/action_dispatch/http/mime_type.rb +31 -24
- data/lib/action_dispatch/http/mime_types.rb +2 -0
- data/lib/action_dispatch/http/parameters.rb +11 -9
- data/lib/action_dispatch/http/permissions_policy.rb +20 -44
- data/lib/action_dispatch/http/rack_cache.rb +2 -0
- data/lib/action_dispatch/http/request.rb +94 -75
- data/lib/action_dispatch/http/response.rb +73 -61
- data/lib/action_dispatch/http/upload.rb +18 -16
- data/lib/action_dispatch/http/url.rb +75 -73
- data/lib/action_dispatch/journey/formatter.rb +13 -6
- data/lib/action_dispatch/journey/gtg/builder.rb +4 -3
- data/lib/action_dispatch/journey/gtg/simulator.rb +2 -0
- data/lib/action_dispatch/journey/gtg/transition_table.rb +10 -8
- data/lib/action_dispatch/journey/nfa/dot.rb +2 -0
- data/lib/action_dispatch/journey/nodes/node.rb +6 -5
- data/lib/action_dispatch/journey/parser.rb +4 -3
- data/lib/action_dispatch/journey/parser_extras.rb +2 -0
- data/lib/action_dispatch/journey/path/pattern.rb +4 -1
- data/lib/action_dispatch/journey/route.rb +9 -7
- data/lib/action_dispatch/journey/router/utils.rb +16 -15
- data/lib/action_dispatch/journey/router.rb +4 -2
- data/lib/action_dispatch/journey/routes.rb +4 -2
- data/lib/action_dispatch/journey/scanner.rb +4 -2
- data/lib/action_dispatch/journey/visitors.rb +2 -0
- data/lib/action_dispatch/journey.rb +2 -0
- data/lib/action_dispatch/log_subscriber.rb +2 -0
- data/lib/action_dispatch/middleware/actionable_exceptions.rb +2 -0
- data/lib/action_dispatch/middleware/assume_ssl.rb +8 -5
- data/lib/action_dispatch/middleware/callbacks.rb +3 -1
- data/lib/action_dispatch/middleware/cookies.rb +119 -104
- data/lib/action_dispatch/middleware/debug_exceptions.rb +13 -5
- data/lib/action_dispatch/middleware/debug_locks.rb +15 -13
- data/lib/action_dispatch/middleware/debug_view.rb +2 -0
- data/lib/action_dispatch/middleware/exception_wrapper.rb +6 -11
- data/lib/action_dispatch/middleware/executor.rb +8 -0
- data/lib/action_dispatch/middleware/flash.rb +63 -51
- data/lib/action_dispatch/middleware/host_authorization.rb +17 -15
- data/lib/action_dispatch/middleware/public_exceptions.rb +8 -6
- data/lib/action_dispatch/middleware/reloader.rb +5 -3
- data/lib/action_dispatch/middleware/remote_ip.rb +77 -72
- data/lib/action_dispatch/middleware/request_id.rb +14 -9
- data/lib/action_dispatch/middleware/server_timing.rb +4 -2
- data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +13 -8
- data/lib/action_dispatch/middleware/session/cookie_store.rb +27 -26
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -3
- data/lib/action_dispatch/middleware/show_exceptions.rb +31 -21
- data/lib/action_dispatch/middleware/ssl.rb +43 -40
- data/lib/action_dispatch/middleware/stack.rb +11 -10
- data/lib/action_dispatch/middleware/static.rb +33 -31
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +1 -1
- data/lib/action_dispatch/railtie.rb +2 -4
- data/lib/action_dispatch/request/session.rb +23 -21
- data/lib/action_dispatch/request/utils.rb +2 -0
- data/lib/action_dispatch/routing/endpoint.rb +2 -0
- data/lib/action_dispatch/routing/inspector.rb +5 -3
- data/lib/action_dispatch/routing/mapper.rb +671 -636
- data/lib/action_dispatch/routing/polymorphic_routes.rb +69 -62
- data/lib/action_dispatch/routing/redirection.rb +37 -32
- data/lib/action_dispatch/routing/route_set.rb +59 -45
- data/lib/action_dispatch/routing/routes_proxy.rb +6 -4
- data/lib/action_dispatch/routing/url_for.rb +130 -125
- data/lib/action_dispatch/routing.rb +150 -148
- data/lib/action_dispatch/system_test_case.rb +91 -81
- data/lib/action_dispatch/system_testing/browser.rb +10 -3
- data/lib/action_dispatch/system_testing/driver.rb +3 -1
- data/lib/action_dispatch/system_testing/server.rb +2 -0
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +32 -21
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +2 -0
- data/lib/action_dispatch/testing/assertion_response.rb +8 -6
- data/lib/action_dispatch/testing/assertions/response.rb +26 -23
- data/lib/action_dispatch/testing/assertions/routing.rb +153 -84
- data/lib/action_dispatch/testing/assertions.rb +2 -0
- data/lib/action_dispatch/testing/integration.rb +223 -222
- data/lib/action_dispatch/testing/request_encoder.rb +2 -0
- data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
- data/lib/action_dispatch/testing/test_process.rb +12 -8
- data/lib/action_dispatch/testing/test_request.rb +3 -1
- data/lib/action_dispatch/testing/test_response.rb +27 -26
- data/lib/action_dispatch.rb +22 -28
- data/lib/action_pack/gem_version.rb +6 -4
- data/lib/action_pack/version.rb +3 -1
- data/lib/action_pack.rb +17 -16
- metadata +39 -16
@@ -1,90 +1,93 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
module ActionDispatch
|
4
6
|
module Routing
|
5
|
-
#
|
7
|
+
# # Action Dispatch Routing UrlFor
|
6
8
|
#
|
7
|
-
# In
|
9
|
+
# In `config/routes.rb` you define URL-to-controller mappings, but the reverse
|
8
10
|
# is also possible: a URL can be generated from one of your routing definitions.
|
9
11
|
# URL generation functionality is centralized in this module.
|
10
12
|
#
|
11
|
-
# See ActionDispatch::Routing for general information about routing and
|
13
|
+
# See ActionDispatch::Routing for general information about routing and
|
14
|
+
# `config/routes.rb`.
|
12
15
|
#
|
13
|
-
#
|
16
|
+
# **Tip:** If you need to generate URLs from your models or some other place,
|
14
17
|
# then ActionDispatch::Routing::UrlFor is what you're looking for. Read on for
|
15
|
-
# an introduction. In general, this module should not be included on its own,
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
# argument:
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# By default, all controllers and views have access to a special version of
|
54
|
-
# that already knows what the current hostname is. So if you use
|
55
|
-
# controllers or your views, then you don't need to explicitly
|
56
|
-
# 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.
|
57
60
|
#
|
58
61
|
# For convenience, mailers also include ActionDispatch::Routing::UrlFor. So
|
59
|
-
# within mailers, you can use url_for. However, mailers cannot access
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
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.
|
65
67
|
#
|
66
|
-
#
|
68
|
+
# ## URL generation for named routes
|
67
69
|
#
|
68
70
|
# UrlFor also allows one to access methods that have been auto-generated from
|
69
71
|
# named routes. For example, suppose that you have a 'users' resource in your
|
70
|
-
#
|
72
|
+
# `config/routes.rb`:
|
71
73
|
#
|
72
|
-
#
|
74
|
+
# resources :users
|
73
75
|
#
|
74
|
-
# This generates, among other things, the method
|
75
|
-
#
|
76
|
-
#
|
77
|
-
# you can do that by including
|
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:
|
78
81
|
#
|
79
|
-
#
|
80
|
-
#
|
82
|
+
# class User < ActiveRecord::Base
|
83
|
+
# include Rails.application.routes.url_helpers
|
81
84
|
#
|
82
|
-
#
|
83
|
-
#
|
85
|
+
# def base_uri
|
86
|
+
# user_path(self)
|
87
|
+
# end
|
84
88
|
# end
|
85
|
-
# end
|
86
89
|
#
|
87
|
-
#
|
90
|
+
# User.find(1).base_uri # => "/users/1"
|
88
91
|
#
|
89
92
|
module UrlFor
|
90
93
|
extend ActiveSupport::Concern
|
@@ -110,66 +113,68 @@ module ActionDispatch
|
|
110
113
|
super
|
111
114
|
end
|
112
115
|
|
113
|
-
# Hook overridden in controller to add request information
|
114
|
-
#
|
115
|
-
# 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.
|
116
118
|
def url_options
|
117
119
|
default_url_options
|
118
120
|
end
|
119
121
|
|
120
|
-
# Generate a URL based on the options provided,
|
121
|
-
# routes defined in
|
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.
|
122
147
|
#
|
123
|
-
# * <tt>:only_path</tt> - If true, the relative URL is returned. Defaults to +false+.
|
124
|
-
# * <tt>:protocol</tt> - The protocol to connect to. Defaults to <tt>"http"</tt>.
|
125
|
-
# * <tt>:host</tt> - Specifies the host the link should be targeted at.
|
126
|
-
# If <tt>:only_path</tt> is false, this option must be
|
127
|
-
# provided either explicitly, or via +default_url_options+.
|
128
|
-
# * <tt>:subdomain</tt> - Specifies the subdomain of the link, using the +tld_length+
|
129
|
-
# to split the subdomain from the host.
|
130
|
-
# If false, removes all subdomains from the host part of the link.
|
131
|
-
# * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+
|
132
|
-
# to split the domain from the host.
|
133
|
-
# * <tt>:tld_length</tt> - Number of labels the TLD id composed of, only used if
|
134
|
-
# <tt>:subdomain</tt> or <tt>:domain</tt> are supplied. Defaults to
|
135
|
-
# <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1.
|
136
|
-
# * <tt>:port</tt> - Optionally specify the port to connect to.
|
137
|
-
# * <tt>:anchor</tt> - An anchor name to be appended to the path.
|
138
|
-
# * <tt>:params</tt> - The query parameters to be appended to the path.
|
139
|
-
# * <tt>:path_params</tt> - The query parameters that will only be used
|
140
|
-
# for the named dynamic segments of path. If unused, they will be discarded.
|
141
|
-
# * <tt>:trailing_slash</tt> - If true, adds a trailing slash, as in <tt>"/archive/2009/"</tt>.
|
142
|
-
# * <tt>:script_name</tt> - Specifies application path relative to domain root. If provided, prepends application path.
|
143
148
|
#
|
144
|
-
# Any other key (
|
145
|
-
#
|
149
|
+
# Any other key (`:controller`, `:action`, etc.) given to `url_for` is forwarded
|
150
|
+
# to the Routes module.
|
146
151
|
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
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'
|
159
164
|
#
|
160
165
|
# Missing routes keys may be filled in from the current request's parameters
|
161
|
-
# (e.g.
|
162
|
-
# placed in the path). Given that the current action has been reached
|
163
|
-
#
|
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`:
|
164
169
|
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
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'
|
168
173
|
#
|
169
|
-
# Notice that no
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
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.
|
173
178
|
def url_for(options = nil)
|
174
179
|
full_url_for(options)
|
175
180
|
end
|
@@ -198,21 +203,21 @@ module ActionDispatch
|
|
198
203
|
|
199
204
|
# Allows calling direct or regular named route.
|
200
205
|
#
|
201
|
-
#
|
206
|
+
# resources :buckets
|
202
207
|
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
208
|
+
# direct :recordable do |recording|
|
209
|
+
# route_for(:bucket, recording.bucket)
|
210
|
+
# end
|
206
211
|
#
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
212
|
+
# direct :threadable do |threadable|
|
213
|
+
# route_for(:recordable, threadable.parent)
|
214
|
+
# end
|
210
215
|
#
|
211
|
-
# This maintains the context of the original caller on
|
212
|
-
#
|
216
|
+
# This maintains the context of the original caller on whether to return a path
|
217
|
+
# or full URL, e.g:
|
213
218
|
#
|
214
|
-
#
|
215
|
-
#
|
219
|
+
# threadable_path(threadable) # => "/buckets/1"
|
220
|
+
# threadable_url(threadable) # => "http://example.com/buckets/1"
|
216
221
|
#
|
217
222
|
def route_for(name, *args)
|
218
223
|
public_send(:"#{name}_url", *args)
|