aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
Commit message (Collapse)AuthorAgeFilesLines
* Revert changes related with api apps in RouteWrapperJorge Bejar2015-06-111-11/+1
| | | | | See the following commit to have context about this change: https://github.com/rails/rails/commit/757a2bc3e3e52a5d9418656928db993db42b741b
* Routes resources avoid :new and :edit endpoints if api_only is enabledJorge Bejar2015-06-112-12/+35
|
* Refactor internal? to query internal_controller? and internal_asset? methodsSantiago Pastorino2015-06-111-1/+11
|
* remove unused codeAaron Patterson2015-06-081-2/+2
|
* we only care about methods that the request object responds toAaron Patterson2015-06-081-2/+1
| | | | | matches? should only deal with methods on the request object, so lets just filter out anything that the request object doesn't respond to
* extract required_defaults from the conditions hash before constructing the routeAaron Patterson2015-06-081-2/+3
| | | | | this way we can remove the strange "respond_to?" conditional in the `matches?` loop
* match method doc fix [ci skip]Mehmet Emin İNAÇ2015-05-301-3/+6
| | | | | | match method without setting `:via` option has been deprecated fix minor typo
* [ci skip] match without via is now deprecatedYoong Kang Lim2015-05-301-1/+1
|
* Use ruby 1.9 lambda syntax in documentations [ci skip]Mehmet Emin İNAÇ2015-05-031-3/+3
|
* Don't reference sprockets assets on action packArthur Neves2015-04-261-1/+1
| | | | | | | | We need to ignore the `assets_prefix` when running a command like `rake routes`. However we cannot reference asserts_prefix from action_pack as that is a sprockets-rails concern. See this is now implemented on sprockets-rails https://github.com/rails/sprockets-rails/commit/85b89c44ad40af3056899808475e6e4bf65c1f5a
* Merge pull request #19700 from tancnle/trivial-shallow-nesting-depth-countRafael Mendonça França2015-04-081-1/+1
|\ | | | | A shorter and more concise version of select..size
| * A shorter and more concise version of select..sizeTan Le2015-04-091-1/+1
| |
* | sort_by instead of sortYang Bo2015-04-081-1/+1
| | | | | | | | | | | | it is avoid sort errot within different and mixed keys. used `sort_by` + `block` to list parameter by keys. keep minimum changes
* | pass a config to the route setAaron Patterson2015-03-051-3/+19
| | | | | | | | | | This way we can get the relative_url_root from the application without setting another global value
* | Drop request class from RouteSet constructor.Aaron Patterson2015-03-041-4/+7
| | | | | | | | | | If you would like to use a custom request class, please subclass and implemet the `request_class` method.
* | Merge pull request #18775 from yasyf/issue_5122Rafael Mendonça França2015-03-031-1/+3
|\ \ | | | | | | | | | Fallback to RAILS_RELATIVE_URL_ROOT in `url_for`
| * | Fallback to RAILS_RELATIVE_URL_ROOT in `url_for`.Yasyf Mohamedali2015-02-241-1/+3
| | | | | | | | | | | | | | | | | | Fixed an issue where the `RAILS_RELATIVE_URL_ROOT` environment variable is not prepended to the path when `url_for` is called. If `SCRIPT_NAME` (used by Rack) is set, it takes precedence.
* | | be optimistic about missing route keysAaron Patterson2015-03-021-13/+15
| | | | | | | | | | | | | | | | | | | | | this patch makes errors slightly more expensive when someone is missing a route key, but in exchange it drops 4 allocations per `url_for` call. Since missing a route key is an error, optimizing for the non-error path seems like a good trade off
* | | use arg size for parallel iterationAaron Patterson2015-03-021-1/+1
| | | | | | | | | | | | | | | we already know the length of the args, so we can use that length for parallel iteration and cut down on allocations for `url_for` calls.
* | | ask the routes objects for its Rack env keyAaron Patterson2015-03-021-0/+2
| | | | | | | | | | | | | | | | | | this centralizes the logic for determining the script name key and drops object allocations when calling `engine_script_name` (which is called on each `url_for`).
* | | refactor `handle_model` to use private helper methods for generationAaron Patterson2015-03-011-8/+6
| | |
* | | drop allocations for string and class polymorphic routesAaron Patterson2015-03-011-3/+3
| | |
* | | move _generate_paths_by_default to where it is usedAaron Patterson2015-03-011-6/+0
| | | | | | | | | | | | | | | _generate_paths_by_default wasn't used in AD::Routing::UrlFor, so we should be able to move it where it is used in AV::Routing
* | | drop allocations when handling model url generationAaron Patterson2015-02-281-1/+1
| | |
* | | Change filter on /rails/info/routes to use an actual path regexp from railsbrainopia2015-02-231-22/+4
|/ / | | | | | | | | | | | | | | Change filter on /rails/info/routes to use an actual path regexp from rails and not approximate javascript version. Oniguruma supports much more extensive list of features than javascript regexp engine. Fixes #18402.
* | Merge pull request #18218 from brainopia/fix_match_shorthand_in_routesRafael Mendonça França2015-02-201-1/+1
|\ \ | | | | | | Don't use shorthand match on routes with inappropriate symbols
| * | Improve shorthand matching for routesbrainopia2015-01-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Shorthand route match is when controller and action are taken literally from path. E.g. get '/foo/bar' # => will use 'foo#bar' as endpoint get '/foo/bar/baz' # => will use 'foo/bar#baz' as endpoint Not any path with level two or more of nesting can be used as shortcut. If path contains any characters outside of /[\w-]/ then it can't be used as such. This commit ensures that invalid shortcuts aren't used. ':controller/:action/postfix' - is an example of invalid shortcut that was previosly matched and led to exception: "ArgumentError - ':controller/:action' is not a supported controller name"
* | | Make the helpers a required argumentEvan Phoenix2015-02-191-2/+2
| | |
* | | Cache url_helpers instead of creating each timeEvan Phoenix2015-02-192-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | This has 2 effects: 1. RoutesProxy is CRAZY faster because it's no longer creating a new Module each time method_missing is hit. 2. It bypasses an existing bug in ruby that makes `class << obj` unsafe to be used in threading contexts.
* | | Skip url_helpers instead of caching, speed up integration testseileencodes2015-02-121-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We shouldn't cache if it's not absolutely necessary. Removes route caching and instead skips using the `url_helpers` is the integration test session doesn't require it. Benchmark ips on integration and controller index method tests below. Without any caching or changes to `#url_helpers`: ``` Calculating ------------------------------------- INDEX: Integration Test 71.000 i/100ms INDEX: Functional Test 99.000 i/100ms ------------------------------------------------- INDEX: Integration Test 728.878 (± 8.0%) i/s - 3.692k INDEX: Functional Test 1.015k (± 6.7%) i/s - 5.148k Comparison: INDEX: Functional Test: 1015.4 i/s INDEX: Integration Test: 728.9 i/s - 1.39x slower ``` With caching on `#url_helpers`: ``` Calculating ------------------------------------- INDEX: Integration Test 74.000 i/100ms INDEX: Functional Test 99.000 i/100ms ------------------------------------------------- INDEX: Integration Test 752.377 (± 6.9%) i/s - 3.774k INDEX: Functional Test 1.021k (± 6.7%) i/s - 5.148k Comparison: INDEX: Functional Test: 1021.1 i/s INDEX: Integration Test: 752.4 i/s - 1.36x slower ``` Afer removing the caching and bypassing the `url_helpers` when not necessary in the session: ``` Calculating ------------------------------------- INDEX: Integration Test 87.000 i/100ms INDEX: Functional Test 97.000 i/100ms ------------------------------------------------- INDEX: Integration Test 828.433 (± 6.4%) i/s - 4.176k INDEX: Functional Test 926.763 (± 7.2%) i/s - 4.656k Comparison: INDEX: Functional Test: 926.8 i/s INDEX: Integration Test: 828.4 i/s - 1.12x slower ```
* | | `RouteSet` should not be listed in the public API [ci skip]Sean Griffin2015-02-031-10/+10
| | | | | | | | | | | | | | | The use of `# :startdoc:` inside of the class was overriding the outer-most `# :nodoc:`, causing it to be listed in the documented API.
* | | Cache `url_helpers` separately for mailersAndrew White2015-02-011-44/+50
| | | | | | | | | | | | | | | The commit 3b63780 re-introduced url helper caching but we need to cache a separate module for Action Mailer without paths.
* | | Cache `url_helpers`eileencodes2015-02-011-42/+44
| | | | | | | | | | | | | | | | | | `url_helpers` used to be memoized. This was lost in a refactoring and this PR adds it back. We noticed this while investigating why integration tests are slower than controller tests.
* | | Preserve default url options when generating URLsTekin Suleyman2015-01-281-3/+4
| | | | | | | | | | | | | | | Fixes an issue that would cause default_url_options to be lost when generating URLs with fewer positional arguments than parameters in the route definition.
* | | improve performance of integration tests.Aaron Patterson2015-01-271-1/+8
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I found delegate to be a bottleneck during integration tests. Here is the test case: ```ruby require 'test_helper' class DocumentsIntegrationTest < ActionDispatch::IntegrationTest test "index" do get '/documents' assert_equal 200, response.status end end Minitest.run_one_method(DocumentsIntegrationTest, 'test_index') StackProf.run(mode: :wall, out: 'stackprof.dump') do 3000.times do Minitest.run_one_method(DocumentsIntegrationTest, 'test_index') end end ``` Top of the stack: ``` [aaron@TC integration_performance_test (master)]$ stackprof stackprof.dump ================================== Mode: wall(1000) Samples: 23694 (7.26% miss rate) GC: 1584 (6.69%) ================================== TOTAL (pct) SAMPLES (pct) FRAME 7058 (29.8%) 6178 (26.1%) block in Module#delegate 680 (2.9%) 680 (2.9%) ActiveSupport::PerThreadRegistry#instance 405 (1.7%) 405 (1.7%) ThreadSafe::NonConcurrentCacheBackend#[] 383 (1.6%) 383 (1.6%) Set#include? 317 (1.3%) 317 (1.3%) ActiveRecord::Base.logger 281 (1.2%) 281 (1.2%) Rack::Utils::HeaderHash#[]= 269 (1.1%) 269 (1.1%) ActiveSupport::Notifications::Fanout::Subscribers::Evented#subscribed_to? 262 (1.1%) 262 (1.1%) block (4 levels) in Class#class_attribute 384 (1.6%) 246 (1.0%) block (2 levels) in Class#class_attribute ``` According to @eileencodes's tests, this speeds up integration tests so that they are only 1.4x slower than functional tests: Before: INDEX: Integration Test: 153.2 i/s - 2.43x slower After: INDEX: Integration Test: 275.1 i/s - 1.41x slower
* | Fix name_for_action in routingrono232015-01-191-2/+3
| |
* | Remove unneeded requiresRafael Mendonça França2015-01-042-2/+0
| | | | | | | | These requires were added only to change deprecation message
* | Remove deprecated usage of string keys in URL helpersRafael Mendonça França2015-01-041-17/+1
| |
* | Remove deprecated `only_path` option on `*_path` helpersRafael Mendonça França2015-01-041-28/+1
| |
* | Remove deprecate `*_path` helpers in email viewsRafael Mendonça França2015-01-041-25/+4
| |
* | Remove deprecated `NamedRouteCollection#helpers`Rafael Mendonça França2015-01-041-8/+0
| |
* | Remove deprecated support to define routes with `:to` option thatRafael Mendonça França2015-01-041-17/+2
| | | | | | | | doesn't contain `#`
* | Fix form_for to work with objects that implement to_modelTravis Grathwell2014-12-291-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if you tried to use form_for with a presenter object that implements to_model, it would crash in action_dispatch/routing/polymorphic_routes.rb when asking the presenter whether it is .persisted? Now, we always ask .persisted? of the to_model object instead. This seems to been an issue since 1606fc9d840da869a60213bc889da6fcf1fdc431 Signed-off-by: Eugenia Dellapenna <eugenia.dellapenna@gmail.com>
* | Remove ActionController::ModelNamingclaudiob2014-12-251-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The methods in these modules are not used anywhere. They used to be invoked in polymorphic_routes.rb but their usage was removed in e821045. What is your opinion about removing these methods? They do belong to the public API, but in reality their code has already been duplicated to ActionView::ModelNaming, since they are used by methods like `dom_id` and `dom_class` to associated records with DOM elements (in ActionView). Please tell me if you think that removing this module is a good idea and, in that case, if the PR is okay as it is, or you'd rather start by showing a deprecation message, and remove the module in Rails 5.1.
* | allow URL helpers to work with optional scopesAlex Robbin2014-12-131-1/+1
| |
* | Fix handling of positional url helper arguments when format is falseTatiana Soukiassian2014-12-131-2/+8
| | | | | | | | | | | | | | There is no need to subtract one from the path_params size when there is no format parameter because it is not present in the path_params array. Fixes #17819.
* | Only check that it is a Rails application onceRafael Mendonça França2014-12-081-5/+7
| | | | | | | | Also avoid using try since is_a? is faster for this case.
* | Mounted Rack apps should have default named routes based on app nameT.J. Schuck2014-12-061-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression in 4.2.0 from 4.1.8. https://github.com/rails/rails/pull/17823 fixed a similar regression regarding _explicitly_ named routes for a mounted Rack app, but there was another regression for the default value. With a route like: Rails.application.routes.draw do mount Mountable::Web, at: 'some_route' end The "Prefix" column of rake routes gives the following: - 4.1.8: mountable_web - 4.2.0.beta1-4: [nothing] - 4.2.0.rc1: [nothing] - 4.2.0.rc2: some_route <- regression This fixes the default to go back to being based off the name of the class like the docs specify: https://github.com/rails/rails/blob/785d04e3109f69d0b9b9f4732179592f0ef04e52/actionpack/lib/action_dispatch/routing/mapper.rb#L558-L560 Explicitly named routes still work correctly per https://github.com/rails/rails/pull/17823: Rails.application.routes.draw do mount Mountable::Web, at: 'some_route', as: 'named' end - 4.1.8: named - 4.2.0.beta1-4: [nothing] - 4.2.0.rc1: [nothing] - 4.2.0.rc2: named
* | Merge pull request #17862 from lucasmazza/lm-hide-actionRafael Mendonça França2014-12-021-0/+2
| | | | | | | | `_generate_paths_by_default` should always be private.
* | Merge pull request #17823 from byroot/fix-mount-rack-apps-with-asSean Griffin2014-11-291-7/+1
|\ \ | | | | | | Pure rack apps can be mounted with a name