aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use match? where we don't need MatchDataAkira Matsuda2019-07-291-5/+5
|
* Use match? where we don't need MatchDataAkira Matsuda2019-07-271-2/+2
| | | | We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Use keyword arguments for ActionDispatch::Routing::Mapper::Mapping constructorAlberto Almagro2019-05-221-14/+17
| | | | | | | | | | This commit changes from constructor's argument list to keyword arguments in order to remove the dependency of remember parameters' positions. It also unifies all parameters extracted from the `scope` into `scope_params`, which also takes care of providing the default values for them.
* Use keyword arguments for ActionDispatch::Journey:Route constructorAlberto Almagro2019-05-221-2/+4
| | | | | | | | | | This commit changes from constructor's argument list to keyword arguments in order to remove the dependency of remember parameters' positions. The constructor already provided a default value for `internal`, this commits takes the chance to also add default values for `precedence` and `scope_options`.
* Keep part when scope option has valueAlberto Almagro2019-05-221-6/+7
| | | | | | | | | When a route was defined within an optional scope, if that route didn't take parameters the scope was lost when using path helpers. This patch ensures scope is kept both when the route takes parameters or when it doesn't. Fixes #33219
* Deduplicate strings held by the routerJean Boussier2019-04-031-3/+7
|
* [ci skip] Doc for shallow: false options should use <tt> for better ↵Abhay Nikam2019-04-031-1/+1
| | | | readability. PR after #24405
* Merge pull request #24405 from waits/shallow-falseRafael França2019-04-021-1/+4
|\ | | | | Honor shallow: false on nested resources
| * Honor shallow: false on nested resourcesDylan Waits2016-04-031-1/+4
| | | | | | | | | | | | | | | | Previously there was no way to place a non-shallow resource inside a parent with `shallow: true` set. Now you can set `shallow: false` on a nested child resource to generate normal (non-shallow) routes for it. Fixes #23890.
* | Raise if resource custom params contain colonsJosua Schmid2019-03-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | After this change it's not possible anymore to configure routes like this: routes.draw do resources :users, param: "name/:sneaky" end Fixes #30467.
* | Add documentation for the resource(s) :param optionJeff Wallace2019-02-211-0/+3
| |
* | Remove unnecessary variable routeAlberto Almagro2018-12-021-11/+2
| | | | | | | | | | The variable `route` was only allocated to hold an object that was immediately returned. This patch removes that variable.
* | Raise an error on root route naming conflicts.Gannon McGibbon2018-11-201-4/+2
| | | | | | | | | | Raises an ArgumentError when multiple root routes are defined in the same context instead of assigning nil names to subsequent roots.
* | Merge pull request #20865 from colavitam/only-except-behaviorRafael Mendonça França2018-11-191-2/+8
|\ \ | | | | | | | | | :only and :except are now chained for routing resource(s)
| * | :only and :except are now chained for routing resource(s)Michael Colavita2015-07-131-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow chaining the :only and :except options for routing resource(s). Previously, the following yielded routes for both show and destroy: resource :account, :only => [:show, :destroy], :except => :destroy This now yields only the show action. This chaining can be useful for passing optional :except options to code that makes use of the :only option (e.g. for a gem with its own routing methods).
* | | Revert "Merge pull request #33970 from rails/eager-url-helpers"schneems2018-10-031-1/+2
| | | | | | | | | | | | | | | | | | | | | Until #34050 can be resolved This reverts commit 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, reversing changes made to 6556898884d636c59baae008e42783b8d3e16440.
* | | Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* | | Merge pull request #34002 from gmcgibbon/fix_deeply_nested_scoped_rootRafael França2018-09-271-1/+1
|\ \ \ | | | | | | | | Fix optionally scoped root route unscoped access
| * | | Fix optionally scoped root route unscoped accessGannon McGibbon2018-09-271-1/+1
| | | |
* | | | Fixing an edge case when using objects as constraintsSimon Courtois2018-09-271-1/+13
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR fixes an issue when the following situation occurs. If you define a class like this class MyConstraint def call(*args) # for some reason this is defined end def matches?(*args) # checking the args end end and try to use it as a constraint get "/", to: "home#show", constraints: MyConstraint.new if its `matches?` method returns `false` there will be an error for the mapper will ask for the constraint arity, thinking it is a proc, lambda or method. This PR checks for the presence of the `arity` method on the constraint calling it only if present, preventing the error while keeping the basic behavior.
* | | Eagerly build the routing helper module after routes are committedAaron Patterson2018-09-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit eagerly builds the route helper module after the routes have been drawn and finalized. This allows us to cache the helper module but not have to worry about people accessing the module while route definition is "in-flight", and automatically deals with cache invalidation as the module is regenerated anytime someone redraws the routes. The restriction this commit introduces is that the url helper module can only be accessed *after* the routes are done being drawn. Refs #24554 and #32892
* | | Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* | | Convert remaining usage of whitelist and blacklistKevin Deisz2018-08-241-2/+2
| | |
* | | Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-281-5/+5
| | | | | | | | | | | | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* | | Rails guides are now served over httpsPaul McMahon2018-07-241-1/+1
| | | | | | | | | | | | | | | http links will be redirected to the https version, but still better to just directly link to the https version.
* | | Cache url helpers moduleAndrew White2018-03-211-1/+2
| | | | | | | | | | | | | | | The urls helpers module returned by Rails.application.routes.url_helpers isn't cached so to prevent the cost of building the module cache it locally.
* | | Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-161-1/+1
| | | | | | | | | | | | | | | Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string.
* | | Fix typos. Improve text_helper documentation.James Lovejoy2018-01-191-3/+3
| | | | | | | | | | | | [ci skip]
* | | Fix CustomUrls#direct doc formattingT.J. Schuck2017-11-221-6/+6
| | | | | | | | | | | | | | | Particularly, the bulleted list was getting formatted as a code block because of the extra level of indentation. Pulling it back to the left makes it render properly as a list instead. [ci skip]
* | | Improve docs of ActionDispatch::Routing::Mapperbogdanvlviv2017-11-031-4/+14
| | |
* | | [Action Pack] require => require_relativeAkira Matsuda2017-10-211-2/+2
| | | | | | | | | | | | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* | | Merge branch 'master' of github.com:rails/docrailsVijay Dev2017-08-261-1/+1
|\ \ \
| * | | [ci skip] Fix a typoyui-knk2017-08-181-1/+1
| | | | | | | | | | | | | | | | We always plural form for `resources` method.
* | | | fix typo in ambiguous route definition error messageZoran Pesic2017-08-181-1/+1
|/ / /
* | | Fix regression from multiple mountpoint supportDavid Rodríguez2017-07-241-0/+5
| | |
* | | [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
| | |
* | | Merge pull request #29655 from kirs/frozen-friendly-ap-arMatthew Draper2017-07-101-1/+2
|\ \ \ | | | | | | | | Prepare AP and AR to be frozen string friendly
| * | | Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-061-1/+2
| | | |
* | | | Allow mounting same engine under several locationsDavid Rodríguez2017-07-051-6/+13
|/ / /
* | | [Action Dispatch] require => require_relativeAkira Matsuda2017-07-011-2/+2
| | |
* | | Fix typo on error message when route definition is ambiguous.André Luis Leal Cardoso Junior2017-06-031-1/+1
| | |
* | | Fix formatting of `direct` and `resolve` doc [ci skip]yuuji.yaginuma2017-06-031-14/+14
| | |
* | | 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.
* | | [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-131-25/+25
| | |
* | | 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-261-1/+1
| | |
* | | [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.
* | | [ci skip] Fix direct/resolve documentation.Kasper Timm Hansen2017-02-211-11/+11
| | | | | | | | | | | | Use double quoted strings, come down hard on some typos.