aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
Commit message (Collapse)AuthorAgeFilesLines
...
* | Use more specific check for :format in route pathAndrew White2017-04-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current check for whether to add an optional format to the path is very lax and will match things like `:format_id` where there are nested resources, e.g: resources :formats do resources :items end Fix this by using a more restrictive regex pattern that looks for the patterns `(.:format)`, `.:format` or `/` at the end of the path. Note that we need to allow for multiple closing parenthesis since the route may be of this form: get "/books(/:action(.:format))", controller: "books" This probably isn't what's intended since it means that the default index action route doesn't support a format but we have a test for it so we need to allow it. Fixes #28517.
* | Merge pull request #28394 from shime/docs-action-dispatchXavier Noria2017-03-225-31/+31
|\ \ | | | | | | [docs] fix ActionDispatch documentation
| * | [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-135-31/+31
| | |
* | | Always use original url_for when generating direct routesAndrew White2017-03-172-1/+9
| | | | | | | | | | | | | | | | | | | | | Action View overrides `url_for` in the view context to render paths by default when using `url_for` and this means that direct route helpers don't get the full url when called with the url suffix. To fix this always call the original `url_for`.
* | | Add support for calling nested direct routes (#28462)Andrew White2017-03-173-24/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Remove unnecessary params mungingAndrew White2017-03-151-2/+1
|/ / | | | | | | | | | | | | | | | | | | In 9b654d4 some params munging was added to ensure that they were set whenever `recognize_path` would call either a proc or callable constraint. Since we no longer mutate the environment hash within the method it's now unnecessary and actually causes params to leak between route matches before checking constraints. Fixes #28398.
* | Fix `direct` with params example [ci skip]yuuji.yaginuma2017-03-061-1/+1
| | | | | | | | | | | | | | Since `ActionController:Parameters` does not inherit `Hash`, need to explicitly convert it to `Hash`. Also, `Parameters#to_h` returns `Hash` whose key is `String`. Therefore, if merge as it is, the value will not be overwritten as expected.
* | Remove unused params.Jerry Tao2017-02-262-2/+2
| |
* | Commit flash changes when using a redirect route.Andrew White2017-02-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | In ca324a0 the flash middleware was effectively removed by its constructor returning the app it was passed and the `commit_flash` call was moved to the `ActionController::Metal#dispatch` method. This broke any redirect routes that modified the flash because the redirect happens before `dispatch` gets called. To fix it, this commit adds a `commit_flash` call in the `serve` method of `ActionDispatch::Routing::Redirect`. Fixes #27992.
* | [ci skip] Fix more quotes in direct/resolve docsAndrew White2017-02-231-3/+3
| | | | | | | | Also correct use of `direct class:` to `resolve` in example.
* | Clarify use of params in `direct`Andrew White2017-02-221-0/+9
| | | | | | | | | | | | | | | | | | 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.
* | Bump removal of `/:controller/:action` to Rails 5.2Andrew White2017-02-221-2/+2
| |
* | [ci skip] Fix direct/resolve documentation.Kasper Timm Hansen2017-02-211-11/+11
| | | | | | | | Use double quoted strings, come down hard on some typos.
* | Split direct method into twoAndrew White2017-02-212-49/+56
| | | | | | | | | | Use a separate method called `resolve` for the custom polymorphic mapping to clarify the API.
* | Push option extract into call methodAndrew White2017-02-212-8/+7
| |
* | Fix typo in exception messageAndrew White2017-02-211-1/+1
| |
* | Prefer remove_method over undef_methodAndrew White2017-02-211-4/+4
| | | | | | | | | | | | Using `undef_method` means that when a route is removed any other implementations of that method in the ancestor chain are inaccessible so instead use `remove_method` which restores access to the ancestor.
* | Support mapping of non-model classesAndrew White2017-02-211-3/+10
| |
* | Raise an error if `direct` is inside a scope blockAndrew White2017-02-211-3/+14
| |
* | Add custom polymorphic mappingAndrew White2017-02-213-56/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Don't allocate a hash unnecessarilyAndrew White2017-02-212-2/+6
| |
* | Only accept symbols and strings for Mapper#directAndrew White2017-02-211-1/+6
| |
* | Rename url_helper to directAndrew White2017-02-211-7/+7
| |
* | Add support for defining custom url helpers in routes.rbAndrew White2017-02-212-0/+116
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Wrap routes.url_helpers.url_for via a proxyAndrew White2017-02-211-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | The singleton url_for on Rails.application.routes.url_helpers isn't the same as the url_for you get when you include the module in your class as the latter has support for polymorphic style routes, etc. whereas the former accepts only a hash and is the underlying implementation defined on ActionDispatch::Routing::RouteSet. This commit changes the singleton method to call through a proxy instance so that it gets the full range of features specified in the documentation for url_for.
* | Merge pull request #27647 from Shopify/fully-eagerload-journeyRafael França2017-01-301-0/+6
|\ \ | | | | | | Fully initialize routes before the first request is handled
| * | Fully initialize routes before the first request is handledJean Boussier2017-01-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `AD::Journey::GTG::Simulator` is lazily built the first time `Journey::Router#find_routes` is invoked, which happens when the first request is served. On large applications with many routes, building the simulator can take several hundred milliseconds (~700ms for us). Triggering this initialization during the boot process reduces the impact of deploys on the application response time.
* | | Add examples for behaviour about redirection with and without options. Fixes ↵Vipul A M2017-01-211-0/+8
| | | | | | | | | | | | #27715 [ci skip] (#27730)
* | | Add missing requireDavid Heinemeier Hansson2017-01-161-0/+1
|/ / | | | | | | This was preventing the test suite from being run in isolation
* | Remove deprecated ActionController::Metal.callRafael Mendonça França2017-01-031-9/+7
| |
* | Privatize unneededly protected methods in Action PackAkira Matsuda2016-12-242-27/+27
| |
* | No need to nodoc private methodsAkira Matsuda2016-12-241-17/+17
| |
* | Revert "fix typo in `match` doc [ci skip]"Jon Moss2016-11-191-1/+1
| |
* | fix typo in `match` doc [ci skip]yuuji.yaginuma2016-11-201-1/+1
| | | | | | | | s/Constrains/Constraints
* | Fix incorrect output from rails routes when using singular resources issue ↵Erick Reyna2016-11-181-5/+5
| | | | | | | | | | | | | | | | | | | | #26606 Rails routes (even rake routes in previous versions) output showed incorrect routes when an application use resource :controller, implying that edit_controller_path match with controller#show. The order of the output has changed to correct this. View #26606 for more information. Added a test case, change unit test in rake to expect the new output. Since the output of resource :controller is changing, the string spected of the railties/test/application/rake_test.rb test_rails_routes_with_controller_environment had to be modified.
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-294-13/+13
| |
* | removes requires already present in active_support/railsXavier Noria2016-10-271-1/+0
| |
* | let Regexp#match? be globally availableXavier Noria2016-10-271-1/+0
| | | | | | | | | | | | Regexp#match? should be considered to be part of the Ruby core library. We are emulating it for < 2.4, but not having to require the extension is part of the illusion of the emulation.
* | Remove deprecated support for passing `:path` and route path as stings in ↵Rafael Mendonça França2016-10-101-12/+1
| | | | | | | | `ActionDispatch::Routing::Mapper#match`
* | Remove deprecated support passing path as `nil` in ↵Rafael Mendonça França2016-10-101-5/+1
| | | | | | | | `ActionDispatch::Routing::Mapper#match`
* | Show an "unmatched constraints" error for mismatching and present paramsChris Carter2016-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Currently a misleading "missing required keys" error is thrown when a param fails to match the constraints of a particular route. This commit ensures that these params are recognised as unmatching rather than missing. Note: this means that a different error message will be provided between optimized and non-optimized path helpers, due to the fact that the former does not check constraints when matching routes. Fixes #26470.
* | Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-13/+13
| | | | | | | | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* | RuboCop is 100% green :tada:Xavier Noria2016-09-021-10/+11
| |
* | fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-012-3/+3
| |
* | Override `respond_to_missing?` instead of `respond_to?` when possibleSean Griffin2016-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | This was almost every case where we are overriding `respond_to?` in a way that mirrors a parallel implementation of `method_missing`. There is one remaining case in Active Model that should probably do the same thing, but had a sufficiently strange implementation that I want to investigate it separately. Fixes #26333.
* | Fix nested multiple rootsRyo Hashimoto2016-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PR #20940 enabled the use of multiple roots with different constraints at the top level but unfortunately didn't work when those roots were inside a namespace and also broke the use of root inside a namespace after a top level root was defined because the check for the existence of the named route used the global :root name and not the namespaced name. This is fixed by using the name_for_action method to expand the :root name to the full namespaced name. We can pass nil for the second argument as we're not dealing with resource definitions so don't need to handle the cases for edit and new routes. Fixes #26148.
* | Change method visibility to be privateRafael Mendonça França2016-08-171-57/+57
| | | | | | | | | | Those methods are only using inside this module and by a private method so they all should be private.
* | Push :defaults extraction down one levelRafael Mendonça França2016-08-171-60/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | Since e852daa6976cc6b6b28ad0c80a188c06e226df3c only the verb methods where extracting the defaults options. It was merged a fix for the `root` method in 31fbbb7faccba25b2e3b5e10b8fca1468579d629 but `match` was still broken since `:defaults` where not extracted. This was causing routes defined using `match` and having the `:defaults` keys to not be recognized. To fix this it was extracted a new private method with the actual content of `match` and the `:defaults` extracting was moved to `match`.
* | Add three new rubocop rulesRafael Mendonça França2016-08-163-8/+8
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | revises more Lint/EndAlignment offensesXavier Noria2016-08-082-6/+6
| |