aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | 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
| | |
* | | Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-2/+0
| | |
* | | applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
| | |
* | | normalizes indentation and whitespace across the projectXavier Noria2016-08-065-238/+238
| | |
* | | remove redundant curlies from hash argumentsXavier Noria2016-08-062-2/+2
| | |
* | | modernizes hash syntax in actionpackXavier Noria2016-08-064-16/+16
| | |
* | | applies new string literal convention in actionpack/libXavier Noria2016-08-066-60/+60
| | | | | | | | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* | | Merge pull request #25913 from chrisarcand/fix-keyed-defaults-with-rootRafael Mendonça França2016-07-271-1/+8
|\ \ \ | | | | | | | | | | | | Fix keyed defaults with root
| * | | Fix 'defaults' option for root routeChris Arcand2016-07-211-1/+8
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | The merging of the 'defaults' option was moved up the stack in e852daa This allows us to see where these options originate from the standard HttpHelpers (get, post, patch, put, delete) Unfortunately this move didn't incorporate the 'root' method, which has always allowed the same 'defaults' option before.
* | | Check `request.path_parameters` encoding at the point they're setGrey Baker2016-07-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | Check for any non-UTF8 characters in path parameters at the point they're set in `env`. Previously they were checked for when used to get a controller class, but this meant routes that went directly to a Rack app, or skipped controller instantiation for some other reason, had to defend against non-UTF8 characters themselves.
* | | Deprecate usage of nil as route pathVolmer2016-07-051-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Rails 4 these kind of routes used to work: ```ruby scope '/*id', controller: :builds, as: :build do get action: :show end ``` But since 1a830cbd830c7f80936dff7e3c8b26f60dcc371d, routes are only created for paths specified as strings or symbols. Implicit `nil` paths are just ignored, with no deprecation warnings or errors. Routes are simply not created. This come as a surprise for people migrating to Rails 5, since the lack of logs or errors makes hard to understand where the problem is. This commit introduces a deprecation warning in case of path as `nil`, while still allowing the route definition.
* | | [ci skip] Fix typo & add link in PolymorphicRoutesAlex Kitchens2016-06-291-2/+2
| | |
* | | Fix setting route's to in a scopePiotr Jakubowski2016-06-281-1/+9
| | | | | | | | | | | | | | | | | | Fixes #25488 97d7dc4 introduced a regression that resulted in ArgumentError when to was in options of the scope and not of particular route.
* | | Prevent `{ internal: true }` from being stored in the routerJon Moss2016-06-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Forgotten followup to #23669 :grimacing: If you went to an internal route (e.g. `/rails/info/routes`), you would previously see the following in your logger: ```bash Processing by Rails::InfoController#routes as HTML Parameters: {"internal"=>true} Rendering /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application Rendered collection of /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb [2 times] (10.5ms) Rendered /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb (2.5ms) Rendered /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application (23.5ms) Completed 200 OK in 50ms (Views: 35.1ms | ActiveRecord: 0.0ms) ``` Now, with this change, you would see: ```bash Processing by Rails::InfoController#routes as HTML Rendering /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application Rendered collection of /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb [2 times] (1.6ms) Rendered /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb (10.2ms) Rendered /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application (17.4ms) Completed 200 OK in 44ms (Views: 28.0ms | ActiveRecord: 0.0ms) ```
* | | Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* | | Replace `loop` to `until`Molchanov Andrey2016-05-071-2/+1
| | |
* | | Add more info to insecure URL generation errorDerek Prior2016-04-262-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | I always appreciate having a bit more information as to why something is now an error. We can use this error to tell people why what they were previously doing is insecure and give them hints on how to fix it. Signed-off-by: Kasper Timm Hansen <kaspth@gmail.com>
* | | Merge pull request #23103 from rails/refactor-handling-of-action-defaultJeremy Daer2016-04-243-16/+6
|\ \ \ | |/ / |/| | | | | Refactor handling of :action default in routing
| * | Refactor handling of :action default in routingAndrew White2016-02-163-16/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #24031 from ↵Jeremy Daer2016-04-191-2/+1
|\ \ \ | | | | | | | | | | | | | | | | | | | | samphilipd/sam/do_not_clobber_options_in_route_definitions Do not destructively mutate passed options hash in route definitions
| * | | Do not destructively mutate passed options hash in route definitionsSam Davies2016-03-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fixes #24030 An example scope might be specified as such: ```ruby HTML = { constraints: { format: :html } }.freeze scope HTML do get 'x' end ``` This currently raises an error because the mapper attempts to destructively modify the passed options hash. This is dangerous because this options hash might even be shared with other scopes. We should instead always instantiate a new object instead of modifying the passed options.
* | | | Pass over all Rails 5 warnings, to make sure:Vipul A M2016-04-122-3/+3
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | - we are ending sentences properly - fixing of space issues - fixed continuity issues in some sentences. Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 . This change reverts making sure we add '.' at end of deprecation sentences. This is to keep sentences within Rails itself consistent and with a '.' at the end.
* | | Niceify the dynamic routes deprecation messagesJon Atack2016-03-031-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up to #23980. - Fix grammar: "be remove" -> "be removed". - Wrap lines at 80 chars. Lurvely ;-)
* | | Deprecate :controller and :action path parametersAndrew White2016-03-011-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | [ci skip] Replace usage of rake routes with rails routesAbhishek Jain2016-02-251-1/+1
| | |
* | | Add `internal` attribute to routesJon Moss2016-02-222-2/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Use a URL instead of an URL everywhereAbhishek Jain2016-02-152-2/+2
| |
* | Fixes routes to match verbs and path with -g optionAbhishek Jain2016-02-111-2/+3
| |