aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use match? where we don't need MatchDataAkira Matsuda2019-07-291-1/+1
|
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-3/+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.
* Change the deprecation message for dynamic routes segment to 6.1Abhay Nikam2019-04-201-2/+2
|
* Simplify and fasten NamedRouteCollection#define_url_helperJean Boussier2019-04-101-12/+10
|
* url -> URL where apt inside actionpack/Sharang Dashputre2019-04-011-1/+1
|
* Revert "Don't handle params option in a special way in url_for helper"Rafael Mendonça França2019-01-161-0/+4
| | | | | | | | | | | This reverts commit e385e4678fc64be6e176c3bdac6641db9fe48d85. While this option was undocumented it exists to make possible to pass parameters to the route helpers that are reserved like `:domain`. While `url_for(domain: 'foo.com')` would generate a URL in the `foo.com` domain `url_for(params: { domain: 'foo.com' })` would generate a URL with `?domain=foo.com`.
* Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-211-4/+4
| | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* Follow up #34064bogdanvlviv2018-10-061-21/+0
| | | | | | | | | The removed code was added in 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, then 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49 was reverted by #34064. But I found that that commit wasn't completely reverted, I guess it was caused by resolving some conflicts during reverting. @schneems could you please confirm that those changes weren't reverted unintentionally, or reject this commit otherwise?
* Revert "Merge pull request #33970 from rails/eager-url-helpers"schneems2018-10-031-19/+2
| | | | | | | Until #34050 can be resolved This reverts commit 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, reversing changes made to 6556898884d636c59baae008e42783b8d3e16440.
* Fix call sitesGannon McGibbon2018-10-021-1/+1
|
* Merge pull request #33256 from ilkkao/ilkkao/remove-unused-params-optionRyuta Kamizono2018-10-011-4/+0
|\ | | | | | | Don't handle params option in a special way in url_for helper
| * Don't handle params option in a special way in url_for helperIlkka Oksanen2018-08-201-4/+0
| |
* | Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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'
* | Routes from Engine Railties should not be an infinite loopAaron Patterson2018-09-261-2/+4
| |
* | Allow helpers to be deferred until the routes have been finalizedAaron Patterson2018-09-251-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ActiveStorage::BaseController subclasses ActionController::Base. ActionController::Base has an "inherited" hook set that includes the routing helpers to any subclass of AC::Base. Since ActiveStorage::BaseController is a subclass of AC::Base, it will get routing helpers included automatically. Unfortunately, when the framework is eagerly loaded, ActiveStorage::BaseController is loaded *before* the applications routes are loaded which means it attempts to include an "in flight" module so it gets an exception. This commit allows a class that's interested in being extended with routing helpers register itself such that when the routes are finalized, it will get the helpers included. If the routes are already finalized, then the helpers get included immediately.
* | Eagerly build the routing helper module after routes are committedAaron Patterson2018-09-251-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
* 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.
* Fix Style/RedundantReturn offensesBart de Water2018-04-211-1/+1
|
* Avoid method_redefined warnings in RouteSet::NamedRouteCollectionutilum2018-02-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` ~/.rbenv/versions/2.5.0/bin/ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib -I../actionview/lib -I../activemodel/lib test/application/routing_test.rb Run options: --seed 5851 .......~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here ....~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here ..........~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here ..... Finished in 13.233638s, 1.9647 runs/s, 5.8185 assertions/s. 26 runs, 77 assertions, 0 failures, 0 errors, 0 skips ``` After: ``` ~/.rbenv/versions/2.5.0/bin/ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib -I../actionview/lib -I../activemodel/lib test/application/routing_test.rb Run options: --seed 38072 .......................... Finished in 12.009632s, 2.1649 runs/s, 6.4115 assertions/s. 26 runs, 77 assertions, 0 failures, 0 errors, 0 skips ```
* Unused core_extAkira Matsuda2018-02-111-1/+0
|
* Make sure assert_recognizes can still find routes mounted after enginesRafael Mendonça França2018-02-091-4/+6
| | | | | Before, if the application defined after an engine this method would not recognize the route since it was not defined insdie the engine.
* Fix optimized url helpers when using relative url rootAndrew White2017-11-281-0/+10
| | | | Fixes #31220.
* Merge pull request #22435 from yui-knk/fix_engine_route_testRafael Mendonça França2017-11-061-0/+7
|\ | | | | | | Make `assert_recognizes` to traverse mounted engines
| * Make `assert_recognizes` to traverse mounted enginesyui-knk2016-04-231-0/+7
| | | | | | | | | | | | Before this commit paths of mounted engines are not traversed when `assert_recognizes` is called, causing strange test results. This commit enable to traverse mounted paths.
* | Change the deprecation horizon of the dynamic routes segment to 6.0Rafael Mendonça França2017-10-231-2/+2
| |
* | [Action Pack] require => require_relativeAkira Matsuda2017-10-211-3/+3
| | | | | | | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* | Clarify intentions around method redefinitionsMatthew Draper2017-09-011-1/+2
| | | | | | | | | | | | | | | | | | Don't use remove_method or remove_possible_method just before a new definition: at best the purpose is unclear, and at worst it creates a race condition. Instead, prefer redefine_method when practical, and silence_redefinition_of_method otherwise.
* | [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-2/+2
|/ /
* | Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-18/+11
|\ \
| * | Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * | Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
| |\ \ | | | | | | | | | | | | Enforce frozen string in Rubocop
| | * | Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| | | |
| * | | Merge pull request #29644 from wilson/unify-route-helper-visibilityMatthew Draper2017-07-011-18/+11
| |\ \ \ | | |/ / | |/| | | | | | Properly register "custom" URL helpers as named helpers.
| | * | Properly register "custom" URL helpers as named helpers.Wilson Bilkovich2017-06-301-18/+10
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* / / [Action Dispatch] require => require_relativeAkira Matsuda2017-07-011-3/+3
|/ /
* | Fix missing formats in route-set URLsJonathan del Strother2017-06-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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!)
* | Reuse the Parameters#to_h check in the routing helpersRafael Mendonça França2017-04-181-5/+1
| | | | | | | | | | Since this protection is now in Parameters we can use it instead of reimplementing again.
* | Merge pull request #28394 from shime/docs-action-dispatchXavier Noria2017-03-221-1/+1
|\ \ | | | | | | [docs] fix ActionDispatch documentation
| * | [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-131-1/+1
| | |
* | | Always use original url_for when generating direct routesAndrew White2017-03-171-1/+5
| | | | | | | | | | | | | | | | | | | | | 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-171-20/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Remove unused params.Jerry Tao2017-02-261-1/+1
| |
* | Bump removal of `/:controller/:action` to Rails 5.2Andrew White2017-02-221-2/+2
| |
* | Split direct method into twoAndrew White2017-02-211-10/+4
| | | | | | | | | | Use a separate method called `resolve` for the custom polymorphic mapping to clarify the API.
* | Push option extract into call methodAndrew White2017-02-211-5/+4
| |