aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
| |
* | Fix typo in exception messageAndrew White2017-02-211-1/+1
| |
* | Prefer remove_method over undef_methodAndrew White2017-02-211-4/+4
| | | | | | | | | | | | Using `undef_method` means that when a route is removed any other implementations of that method in the ancestor chain are inaccessible so instead use `remove_method` which restores access to the ancestor.
* | Add custom polymorphic mappingAndrew White2017-02-211-43/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the use of `direct` to specify custom mappings for polymorphic_url, e.g: resource :basket direct(class: "Basket") { [:basket] } This will then generate the following: >> link_to "Basket", @basket => <a href="/basket">Basket</a> More importantly it will generate the correct url when used with `form_for`. Fixes #1769.
* | Don't allocate a hash unnecessarilyAndrew White2017-02-211-1/+5
| |
* | Add support for defining custom url helpers in routes.rbAndrew White2017-02-211-0/+75
| | | | | | | | | | | | | | | | | | | | | | Allow the definition of custom url helpers that will be available automatically wherever standard url helpers are available. The current solution is to create helper methods in ApplicationHelper or some other helper module and this isn't a great solution since the url helper module can be called directly or included in another class which doesn't include the normal helper modules. Reference #22512.
* | Wrap routes.url_helpers.url_for via a proxyAndrew White2017-02-211-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | The singleton url_for on Rails.application.routes.url_helpers isn't the same as the url_for you get when you include the module in your class as the latter has support for polymorphic style routes, etc. whereas the former accepts only a hash and is the underlying implementation defined on ActionDispatch::Routing::RouteSet. This commit changes the singleton method to call through a proxy instance so that it gets the full range of features specified in the documentation for url_for.
* | Fully initialize routes before the first request is handledJean Boussier2017-01-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | `AD::Journey::GTG::Simulator` is lazily built the first time `Journey::Router#find_routes` is invoked, which happens when the first request is served. On large applications with many routes, building the simulator can take several hundred milliseconds (~700ms for us). Triggering this initialization during the boot process reduces the impact of deploys on the application response time.
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-5/+5
| |
* | removes requires already present in active_support/railsXavier Noria2016-10-271-1/+0
| |
* | 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-011-2/+2
| |
* | Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-061-46/+46
| |
* | remove redundant curlies from hash argumentsXavier Noria2016-08-061-1/+1
| |
* | modernizes hash syntax in actionpackXavier Noria2016-08-061-2/+2
| |