| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
|\
| |
| |
| | |
Enforce frozen string in Rubocop
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
CustomUrlHelpers were introduced in ce7d5fb2e6, closing issue #22512.
They currently register themselves in an ivar that is never accessed.
This change removes the @custom_helpers special-case, and registers them
the way named routes are normally handled.
Without this, you can get route_defined?(:example_url) == false, while
still being able to call url_helpers.example_url and example_path.
Various popular gems such as 'rspec-rails' make use of route_defined?()
when determining how to proxy method calls or whether to define a route.
|
|
|
|
|
|
|
|
|
|
|
| |
Before this change, handle_positional_args would end up mutating @segment_keys
if inner_options included path components. Subsequent calls would then
be missing the implicit path components.
eg:
user_path(1, :json) # => "/users/1.json" (correct)
user_path(1, format: :json) # => "/users/1.json" (correct, but @segment_keys was mutated)
user_path(1, :json) # => "/users/1" (oh no!)
|
|
|
|
|
| |
Since this protection is now in Parameters we can use it instead of
reimplementing again.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Not all requirements can be expressed in terms of polymorphic url
options so add a `route_for` method that allows calling another
direct route (or regular named route) which a set of arguments, e.g:
resources :buckets
direct :recordable do |recording|
route_for(:bucket, recording.bucket)
end
direct :threadable do |threadable|
route_for(:recordable, threadable.parent)
end
This maintains the context of the original caller, e.g.
threadable_path(threadable) # => /buckets/1
threadable_url(threadable) # => http://example.com/buckets/1
|
|
|
|
|
|
|
|
|
| |
Since a `direct` url helper block is evaluated using `instance_exec`
then methods that are available in the instance context can be
accessed, e.g. the params object in a controller action or view.
This wasn't clear from the example so expand on that point and add
a test case for this situation.
|
|
|
|
|
| |
Use a separate method called `resolve` for the custom polymorphic
mapping to clarify the API.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allow the use of `direct` to specify custom mappings for polymorphic_url, e.g:
resource :basket
direct(class: "Basket") { [:basket] }
This will then generate the following:
>> link_to "Basket", @basket
=> <a href="/basket">Basket</a>
More importantly it will generate the correct url when used with `form_for`.
Fixes #1769.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Allow the definition of custom url helpers that will be available
automatically wherever standard url helpers are available. The
current solution is to create helper methods in ApplicationHelper
or some other helper module and this isn't a great solution since
the url helper module can be called directly or included in another
class which doesn't include the normal helper modules.
Reference #22512.
|
|
|
|
| |
Follow up to 79a5ea9eadb4d43b62afacedc0706cbe88c54496
|
|
|
|
|
|
|
|
| |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
|
| |
- Remove dead classes / dead code
- Move class definitions to where they are used, don't define in a
shared space
|
|\
| |
| |
| | |
Refactor handling of :action default in routing
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The longstanding convention in Rails is that if the :action parameter
is missing or nil then it defaults to 'index'. Up until Rails 5.0.0.beta1
this was handled slightly differently than other routing defaults by
deleting it from the route options and adding it to the recall parameters.
With the recent focus of removing unnecessary duplications this has
exposed a problem in this strategy - we are now mutating the request's
path parameters and causing problems for later url generation. This will
typically affect url_for rather a named url helper since the latter
explicitly pass :controller, :action, etc.
The fix is to add a default for :action in the route class if the path
contains an :action segment and no default is passed. This change also
revealed an issue with the parameterized part expiry in that it doesn't
follow a right to left order - as soon as a dynamic segment is required
then all other segments become required.
Fixes #23019.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Allowing :controller and :action values to be specified via the path
in config/routes.rb has been an underlying cause of a number of issues
in Rails that have resulted in security releases. In light of this it's
better that controllers and actions are explicitly whitelisted rather
than trying to blacklist or sanitize 'bad' values.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is meant to provide a way for Action Cable, Sprockets, and possibly
other Rack applications to mark themselves as internal, and to exclude
themselves from the routing inspector, and thus `rails routes` / `rake
routes`.
I think this is the only way to have mounted Rack apps be marked as
internal, within AD/Journey. Another option would be to create an array
of regexes for internal apps, and then to iterate over that everytime a
request comes through. Also, I only had the first `add_route` method set
`internal`'s default to false, to avoid littering it all over the
codebase.
|
|
|
|
|
|
|
|
|
|
| |
Add two options: `-c` and `-g`.
`-g` option returns the urls name, verb and path fields that match the pattern.
`-c` option returns the urls for specific controller.
Fixes #18902, and Fixes #20420
[Anton Davydov & Vipul A M]
|
|
|
|
|
|
|
| |
- `CONTROLLER` argument can now be supplied in different ways (Rails::WelcomeController, Rails::Welcome, rails/welcome)
- If `CONTROLLER` argument was supplied but it does not exist, will warn the user that this controller does not exist
- If `CONTROLLER` argument was supplied and no routes could be found matching this filter, will warn the user that no routes were found matching the supplied filter
- If no routes were defined in the config/routes.rb file, will warn the user with the original message
|
| |
|
|
|
|
|
|
|
|
|
| |
By [this commit](https://github.com/rails/rails/commit/0b476de445faf330c58255e2ec3eea0f3a7c1bfc)
`Journey::Route#verb` need not to return verb as regexp.
The returned value is used by inspector, so change it to be a string.
Add inspect_with_multiple_verbs test case to keep the behavior of
inspector correctly.
|
|\
| |
| | |
Fix broken IPv6 addresses handling
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|/
|
|
| |
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
|
|
|
|
| |
Change filter on /rails/info/routes to use an actual path regexp from rails
and not approximate javascript version. Oniguruma supports much more
extensive list of features than javascript regexp engine.
Fixes #18402.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a regression in 4.2.0 from 4.1.8.
https://github.com/rails/rails/pull/17823 fixed a similar regression regarding _explicitly_ named routes for a mounted Rack app, but there was another regression for the default value.
With a route like:
Rails.application.routes.draw do
mount Mountable::Web, at: 'some_route'
end
The "Prefix" column of rake routes gives the following:
- 4.1.8: mountable_web
- 4.2.0.beta1-4: [nothing]
- 4.2.0.rc1: [nothing]
- 4.2.0.rc2: some_route <- regression
This fixes the default to go back to being based off the name of the class like the docs specify: https://github.com/rails/rails/blob/785d04e3109f69d0b9b9f4732179592f0ef04e52/actionpack/lib/action_dispatch/routing/mapper.rb#L558-L560
Explicitly named routes still work correctly per https://github.com/rails/rails/pull/17823:
Rails.application.routes.draw do
mount Mountable::Web, at: 'some_route', as: 'named'
end
- 4.1.8: named
- 4.2.0.beta1-4: [nothing]
- 4.2.0.rc1: [nothing]
- 4.2.0.rc2: named
|
|
|
|
| |
See https://github.com/rails/rails/commit/9b15828b5c347395b42066a588c88e5eb4e72279#commitcomment-8764492
|
|
|
|
|
|
| |
Fixes https://github.com/rails/rails/issues/16958
[Byron Bischoff & Melanie Gilman]
|
|
|
|
|
|
|
|
|
|
|
|
| |
In cases where this option is set to `true`, the option is redundant and can
be safely removed; otherwise, the corresponding `*_url` helper should be
used instead.
Fixes #17294.
See also #17363.
[Dan Olson, Godfrey Chan]
|
|
|
|
|
|
|
|
| |
This reverts commit 9d05d6de52871e57bfbf54a60de005e8a5f5b0e4, reversing
changes made to 0863c9248fd47a15e88e05ce4fcd80966684c0e3.
The change in the behaviour reported at #16958 doesn't exist since 4.0
and 4.1 works in the same way
|