aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
Commit message (Collapse)AuthorAgeFilesLines
* 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-032-20/+4
| | | | | | | 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-293-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | 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-252-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-232-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| |
* | Fix `rails routes -c` for controller name consists of multiple word.Yoshiyuki Kinjo2018-08-201-1/+1
|/
* 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-243-4/+4
| | | | | 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
|
* Small doc fixesT.J. Schuck2018-04-021-1/+1
| | | | [ci skip]
* Make engine check more explicitAndrew White2018-03-251-6/+9
| | | | | | | | Not everything that responds to `routes` is a Rails engine - for example a Grape API endpoint will have a `routes` method but can't be used with `assert_recognizes` as it doesn't respond to `recognize_path_with_request`. Fixes #32312.
* 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.
* Rely on Rails::Command's help output.Kasper Timm Hansen2018-03-131-26/+21
| | | | | | | | | | | | | | | | | | | | | We end up with: ``` Usage: bin/rails routes [options] Options: -c, [--controller=CONTROLLER] # Filter by a specific controller, e.g. PostsController or Admin::PostsController. -g, [--grep=GREP] # Grep routes by a specific pattern. -E, [--expanded], [--no-expanded] # Print routes expanded vertically with parts explained. ``` which does miss the bit about routes being printed in order. Also: * Renames options to ease help output readability, then clarifies each option. * Fixes a bunch of indentation.
* Introduce `ActionDispatch::Routing::ConsoleFormatter::Base`bogdanvlviv2018-03-131-41/+34
| | | | | | | | | | | | | | - Create `Base` and inherit `Sheet` and `Expanded` in order to - prevent code duplication. - Remove trailing "\n" for components of `Expanded`. - There is no need for `Expanded#header` to return `@buffer` so return `nil` instead. - Change `no_routes` message "No routes were found for this controller" since if use `-g`, it sounds incorrect. - Display `No routes were found for this controller.` if apply `-c`. - Display `No routes were found for this grep pattern.` if apply `-g`. Related to #32130
* Merge pull request #32160 from bogdanvlviv/improve-rails-routes-expandedKasper Timm Hansen2018-03-111-1/+10
|\ | | | | Draw line of a route name to the end of row console on `rails routes --expanded`
| * Draw line of a route name to the end of row console on `rails routes --expanded`bogdanvlviv2018-03-051-1/+10
| | | | | | | | | | | | | | In order to get width of console use `IO::console_size`, See https://ruby-doc.org/stdlib-2.4.1/libdoc/io/console/rdoc/IO.html#method-c-console_size Related to #32130
* | Change doc for "polymorphic_path" in polymorphic_routes.rbMahmoud2018-03-091-2/+1
| | | | | | | | | | The method 'polymorphic_path' is not using 'polymorphic_url' with `routing_type: :path` anymore in polymorphic_routes.rb
* | Quote string return values in doc examples [ci skip]Andrew White2018-03-081-2/+2
| |
* | Add example of maintaining context with `route_for`Andrew White2018-03-081-0/+6
| | | | | | | | [ci skip]
* | Express `ActionDispatch::Routing::UrlFor#route_for` as public apibogdanvlviv2018-03-071-1/+13
|/ | | | | | | | | This method was added by #28462 but marked as private api. Since `route_for` looks good in pair with `ActionDispatch::Routing::Mapper::CustomUrls#direct` let's make it as public api. We use it in https://github.com/rails/rails/blob/e83575ff533690db86c92447a539d76b648e9fed/activestorage/config/routes.rb Closes #31417
* `ConsoleFormatter` is no longer used as a classRyuta Kamizono2018-03-021-2/+2
| | | | It is used as a namespace for `Sheet` and `Expanded`.
* Add --expanded option to "rails routes"Benoit Tigeot2018-02-281-37/+90
| | | | | | | | | | | | | | | | | | | | | | | | | When using rails routes with small terminal or complicated routes it can be very difficult to understand where is the element listed in header. psql had the same issue, that's why they created "expanded mode" you can switch using `\x` or by starting psql with ``` -x --expanded Turn on the expanded table formatting mode. This is equivalent to the \x command. ``` The output is similar to one implemented here for rails routes: db_user-# \du List of roles -[ RECORD 1 ]---------------------------------------------- Role name | super Attributes | Superuser, Create role, Create DB Member of | {} -[ RECORD 2 ]---------------------------------------------- Role name | role Attributes | Superuser, Create role, Create DB, Replication Member of | {}
* 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 ```
* Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-162-6/+5
| | | | | 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.
* 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 typos. Improve text_helper documentation.James Lovejoy2018-01-191-3/+3
| | | | [ci skip]
* Fix optimized url helpers when using relative url rootAndrew White2017-11-281-0/+10
| | | | Fixes #31220.
* 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]
* Update incorrect backtick usage in RDoc to teletypeT.J. Schuck2017-11-221-1/+1
| | | [ci skip]
* Merge pull request #22435 from yui-knk/fix_engine_route_testRafael Mendonça França2017-11-063-6/+15
|\ | | | | | | Make `assert_recognizes` to traverse mounted engines
| * Make `assert_recognizes` to traverse mounted enginesyui-knk2016-04-233-6/+15
| | | | | | | | | | | | 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.
* | Improve docs of ActionDispatch::Routing::Mapperbogdanvlviv2017-11-031-4/+14
| |
* | 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-213-7/+7
| | | | | | | | | | 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.
* | 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.
* | | Use tt in doc for ActionPack [ci skip]Yoshiyuki Hirano2017-08-262-4/+4
| | |
* | | fix typo in ambiguous route definition error messageZoran Pesic2017-08-181-1/+1
|/ /
* | Use frozen string literal in actionpack/Kir Shatrov2017-07-296-0/+12
| |