Skip to content

Commit 5c0b749

Browse files
committed
Revert "Deprecate hash key path mapping"
This reverts commit 1b40bfc. Reason: So far the deprecation didn't show that will provide performance improvements, and it's not clear that the new syntax is better than the old one. To avoid churn to the users, we should keep the old syntax for now.
1 parent 7ed09d3 commit 5c0b749

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+431
-466
lines changed

actioncable/lib/action_cable/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Engine < Rails::Engine # :nodoc:
6464
config = app.config
6565
unless config.action_cable.mount_path.nil?
6666
app.routes.prepend do
67-
mount ActionCable.server, at: config.action_cable.mount_path, internal: true, anchor: true
67+
mount ActionCable.server => config.action_cable.mount_path, internal: true, anchor: true
6868
end
6969
end
7070
end

actionmailbox/config/routes.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
Rails.application.routes.draw do
44
scope "/rails/action_mailbox", module: "action_mailbox/ingresses" do
5-
post "/postmark/inbound_emails", to: "postmark/inbound_emails#create", as: :rails_postmark_inbound_emails
6-
post "/relay/inbound_emails", to: "relay/inbound_emails#create", as: :rails_relay_inbound_emails
7-
post "/sendgrid/inbound_emails", to: "sendgrid/inbound_emails#create", as: :rails_sendgrid_inbound_emails
5+
post "/postmark/inbound_emails" => "postmark/inbound_emails#create", as: :rails_postmark_inbound_emails
6+
post "/relay/inbound_emails" => "relay/inbound_emails#create", as: :rails_relay_inbound_emails
7+
post "/sendgrid/inbound_emails" => "sendgrid/inbound_emails#create", as: :rails_sendgrid_inbound_emails
88

99
# Mandrill checks for the existence of a URL with a HEAD request before it will create the webhook.
10-
get "/mandrill/inbound_emails", to: "mandrill/inbound_emails#health_check", as: :rails_mandrill_inbound_health_check
11-
post "/mandrill/inbound_emails", to: "mandrill/inbound_emails#create", as: :rails_mandrill_inbound_emails
10+
get "/mandrill/inbound_emails" => "mandrill/inbound_emails#health_check", as: :rails_mandrill_inbound_health_check
11+
post "/mandrill/inbound_emails" => "mandrill/inbound_emails#create", as: :rails_mandrill_inbound_emails
1212

1313
# Mailgun requires that a webhook's URL end in 'mime' for it to receive the raw contents of emails.
14-
post "/mailgun/inbound_emails/mime", to: "mailgun/inbound_emails#create", as: :rails_mailgun_inbound_emails
14+
post "/mailgun/inbound_emails/mime" => "mailgun/inbound_emails#create", as: :rails_mailgun_inbound_emails
1515
end
1616

1717
# TODO: Should these be mounted within the engine only?
@@ -20,7 +20,7 @@
2020
get "inbound_emails/sources/new", to: "inbound_emails/sources#new", as: :new_rails_conductor_inbound_email_source
2121
post "inbound_emails/sources", to: "inbound_emails/sources#create", as: :rails_conductor_inbound_email_sources
2222

23-
post ":inbound_email_id/reroute", to: "reroutes#create", as: :rails_conductor_inbound_email_reroute
24-
post ":inbound_email_id/incinerate", to: "incinerates#create", as: :rails_conductor_inbound_email_incinerate
23+
post ":inbound_email_id/reroute" => "reroutes#create", as: :rails_conductor_inbound_email_reroute
24+
post ":inbound_email_id/incinerate" => "incinerates#create", as: :rails_conductor_inbound_email_incinerate
2525
end
2626
end

actionmailer/lib/action_mailer/railtie.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ class Railtie < Rails::Railtie # :nodoc:
8484

8585
if options.show_previews
8686
app.routes.prepend do
87-
get "/rails/mailers", to: "rails/mailers#index", internal: true
88-
get "/rails/mailers/download/*path", to: "rails/mailers#download", internal: true
89-
get "/rails/mailers/*path", to: "rails/mailers#preview", internal: true
87+
get "/rails/mailers" => "rails/mailers#index", internal: true
88+
get "/rails/mailers/download/*path" => "rails/mailers#download", internal: true
89+
get "/rails/mailers/*path" => "rails/mailers#preview", internal: true
9090
end
9191
end
9292
end

actionmailer/test/url_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class WelcomeController < ActionController::Base
99
AppRoutes = ActionDispatch::Routing::RouteSet.new
1010

1111
AppRoutes.draw do
12-
get "/welcome", to: "foo#bar", as: "welcome"
13-
get "/dummy_model", to: "foo#baz", as: "dummy_model"
12+
get "/welcome" => "foo#bar", as: "welcome"
13+
get "/dummy_model" => "foo#baz", as: "dummy_model"
1414
get "/welcome/greeting", to: "welcome#greeting"
1515
get "/a/b(/:id)", to: "a#b"
1616
end

actionpack/CHANGELOG.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@
1414

1515
*Matthew Nguyen*
1616

17-
* Deprecate drawing routes with hash key paths to make routing faster.
18-
19-
```ruby
20-
# Before
21-
get "/users" => "users#index"
22-
post "/logout" => :sessions
23-
mount MyApp => "/my_app"
24-
25-
# After
26-
get "/users", to: "users#index"
27-
post "/logout", to: "sessions#logout"
28-
mount MyApp, at: "/my_app"
29-
```
30-
31-
*Gannon McGibbon*
32-
3317
* Deprecate drawing routes with multiple paths to make routing faster.
3418
You may use `with_options` or a loop to make drawing multiple paths easier.
3519

actionpack/lib/action_dispatch/routing.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ module ActionDispatch
118118
#
119119
# # In config/routes.rb
120120
# controller :blog do
121-
# get 'blog/show', to: :list
122-
# get 'blog/delete', to: :delete
123-
# get 'blog/edit', to: :edit
121+
# get 'blog/show' => :list
122+
# get 'blog/delete' => :delete
123+
# get 'blog/edit' => :edit
124124
# end
125125
#
126126
# # provides named routes for show, delete, and edit

actionpack/lib/action_dispatch/routing/mapper.rb

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,6 @@ def mount(app, options = nil)
631631
options = app
632632
app, path = options.find { |k, _| k.respond_to?(:call) }
633633
options.delete(app) if app
634-
hash_key_app = true
635634
end
636635

637636
raise ArgumentError, "A rack application must be specified" unless app.respond_to?(:call)
@@ -642,18 +641,6 @@ def mount(app, options = nil)
642641
or
643642
mount(SomeRackApp => "some_route")
644643
MSG
645-
ActionDispatch.deprecator.warn(<<-MSG.squish) if hash_key_app
646-
Mounting an engine with a hash key name is deprecated and
647-
will be removed in Rails 8.1. Please use the `at:` option instead.
648-
649-
Instead of:
650-
651-
mount(SomeRackApp => "some_route")
652-
653-
Please use:
654-
655-
mount SomeRackApp, at: "some_route"
656-
MSG
657644

658645
rails_app = rails_app? app
659646
options[:as] ||= app_name(app, rails_app)
@@ -1699,20 +1686,6 @@ def match(path, *rest, &block)
16991686

17001687
raise ArgumentError, "Route path not specified" if path.nil?
17011688

1702-
ActionDispatch.deprecator.warn(<<-MSG.squish)
1703-
Drawing a route with a hash key name is deprecated and
1704-
will be removed in Rails 8.1. Please use the `to:` option with
1705-
"controller#action" syntax instead.
1706-
1707-
Instead of:
1708-
1709-
match "path" => "controller#action`
1710-
1711-
Please use:
1712-
1713-
match "path", to: "controller#action"
1714-
MSG
1715-
17161689
case to
17171690
when Symbol
17181691
options[:action] = to

actionpack/lib/action_dispatch/routing/redirection.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def inspect
148148
module Redirection
149149
# Redirect any path to another path:
150150
#
151-
# get "/stories", to: redirect("/posts")
151+
# get "/stories" => redirect("/posts")
152152
#
153153
# This will redirect the user, while ignoring certain parts of the request,
154154
# including query string, etc. `/stories`, `/stories?foo=bar`, etc all redirect
@@ -157,7 +157,7 @@ module Redirection
157157
# The redirect will use a `301 Moved Permanently` status code by default. This
158158
# can be overridden with the `:status` option:
159159
#
160-
# get "/stories", to: redirect("/posts", status: 307)
160+
# get "/stories" => redirect("/posts", status: 307)
161161
#
162162
# You can also use interpolation in the supplied redirect argument:
163163
#
@@ -199,7 +199,7 @@ module Redirection
199199
# allowing you to reuse common redirect routes. The call method must accept two
200200
# arguments, params and request, and return a string.
201201
#
202-
# get 'accounts/:name', to: redirect(SubdomainRedirector.new('api'))
202+
# get 'accounts/:name' => redirect(SubdomainRedirector.new('api'))
203203
#
204204
def redirect(*args, &block)
205205
options = args.extract_options!

actionpack/test/controller/base_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def setup
215215
def test_url_for_query_params_included
216216
rs = ActionDispatch::Routing::RouteSet.new
217217
rs.draw do
218-
get "home", to: "pages#home"
218+
get "home" => "pages#home"
219219
end
220220

221221
options = {
@@ -316,7 +316,7 @@ class OptionalDefaultUrlOptionsControllerTest < ActionController::TestCase
316316
def test_default_url_options_override_missing_positional_arguments
317317
with_routing do |set|
318318
set.draw do
319-
get "/things/:id(.:format)", to: "things#show", as: :thing
319+
get "/things/:id(.:format)" => "things#show", :as => :thing
320320
end
321321
assert_equal "/things/1.atom", thing_path("1")
322322
assert_equal "/things/default-id.atom", thing_path

actionpack/test/controller/integration_test.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def with_test_route_set
649649
end
650650

651651
set.draw do
652-
get "moved", to: redirect("/method")
652+
get "moved" => redirect("/method")
653653

654654
ActionDispatch.deprecator.silence do
655655
match ":action", to: controller, via: [:get, :post], as: :action
@@ -784,9 +784,9 @@ def self.call(*)
784784
get "foo", to: "application_integration_test/test#index", as: :foo
785785
get "bar", to: "application_integration_test/test#index", as: :bar
786786

787-
mount MountedApp, at: "/mounted", as: "mounted"
788-
get "fooz", to: proc { |env| [ 200, { ActionDispatch::Constants::X_CASCADE => "pass" }, [ "omg" ] ] },
789-
anchor: false
787+
mount MountedApp => "/mounted", :as => "mounted"
788+
get "fooz" => proc { |env| [ 200, { ActionDispatch::Constants::X_CASCADE => "pass" }, [ "omg" ] ] },
789+
:anchor => false
790790
get "fooz", to: "application_integration_test/test#index"
791791
end
792792

@@ -890,7 +890,7 @@ def headers
890890
test "doesn't call controller's headers method" do
891891
with_routing do |routes|
892892
routes.draw do
893-
get "/ok", to: "controller_with_headers_method_integration_test/test#index"
893+
get "/ok" => "controller_with_headers_method_integration_test/test#index"
894894
end
895895

896896
get "/ok"
@@ -941,10 +941,10 @@ def app
941941
default_url_options host: "foo.com"
942942

943943
scope module: "url_options_integration_test" do
944-
get "/foo", to: "foo#index", as: :foos
945-
get "/foo/:id", to: "foo#show", as: :foo
946-
get "/foo/:id/edit", to: "foo#edit", as: :edit_foo
947-
get "/bar", to: "bar#index", as: :bars
944+
get "/foo" => "foo#index", :as => :foos
945+
get "/foo/:id" => "foo#show", :as => :foo
946+
get "/foo/:id/edit" => "foo#edit", :as => :edit_foo
947+
get "/bar" => "bar#index", :as => :bars
948948
end
949949
end
950950

@@ -1004,7 +1004,7 @@ def app
10041004
end
10051005

10061006
routes.draw do
1007-
get "/foo/status", to: "head_with_status_action_integration_test/foo#status"
1007+
get "/foo/status" => "head_with_status_action_integration_test/foo#status"
10081008
end
10091009

10101010
test "get /foo/status with head result does not cause stack overflow error" do
@@ -1067,7 +1067,7 @@ def test_request
10671067
with_routing do |routes|
10681068
routes.draw do
10691069
ActionDispatch.deprecator.silence do
1070-
get ":action", to: FooController
1070+
get ":action" => FooController
10711071
end
10721072
end
10731073

@@ -1115,7 +1115,7 @@ def test_standard_json_encoding_works
11151115
with_routing do |routes|
11161116
routes.draw do
11171117
ActionDispatch.deprecator.silence do
1118-
post ":action", to: FooController
1118+
post ":action" => FooController
11191119
end
11201120
end
11211121

@@ -1142,7 +1142,7 @@ def test_doesnt_mangle_request_path
11421142
with_routing do |routes|
11431143
routes.draw do
11441144
ActionDispatch.deprecator.silence do
1145-
post ":action", to: FooController
1145+
post ":action" => FooController
11461146
end
11471147
end
11481148

@@ -1203,7 +1203,7 @@ def test_parsed_body_without_as_option
12031203
with_routing do |routes|
12041204
routes.draw do
12051205
ActionDispatch.deprecator.silence do
1206-
get ":action", to: FooController
1206+
get ":action" => FooController
12071207
end
12081208
end
12091209

@@ -1217,7 +1217,7 @@ def test_get_parameters_with_as_option
12171217
with_routing do |routes|
12181218
routes.draw do
12191219
ActionDispatch.deprecator.silence do
1220-
get ":action", to: FooController
1220+
get ":action" => FooController
12211221
end
12221222
end
12231223

@@ -1231,7 +1231,7 @@ def test_get_request_with_json_uses_method_override_and_sends_a_post_request
12311231
with_routing do |routes|
12321232
routes.draw do
12331233
ActionDispatch.deprecator.silence do
1234-
get ":action", to: FooController
1234+
get ":action" => FooController
12351235
end
12361236
end
12371237

@@ -1247,7 +1247,7 @@ def test_get_request_with_json_excludes_null_query_string
12471247
with_routing do |routes|
12481248
routes.draw do
12491249
ActionDispatch.deprecator.silence do
1250-
get ":action", to: FooController
1250+
get ":action" => FooController
12511251
end
12521252
end
12531253

@@ -1262,7 +1262,7 @@ def post_to_foos(as:)
12621262
with_routing do |routes|
12631263
routes.draw do
12641264
ActionDispatch.deprecator.silence do
1265-
post ":action", to: FooController
1265+
post ":action" => FooController
12661266
end
12671267
end
12681268

@@ -1358,8 +1358,8 @@ def remove_dumps
13581358
end
13591359

13601360
routes.draw do
1361-
get "/", to: "page_dump_integration_test/foo#index"
1362-
get "/redirect", to: "page_dump_integration_test/foo#redirect"
1361+
get "/" => "page_dump_integration_test/foo#index"
1362+
get "/redirect" => "page_dump_integration_test/foo#redirect"
13631363
end
13641364

13651365
test "save_and_open_page saves a copy of the page and call to Launchy" do

0 commit comments

Comments
 (0)