Skip to content

Commit ac0417c

Browse files
committed
Merge pull request rails#25693 from volmer/master
Deprecate usage of nil as route path
1 parent 0a189f6 commit ac0417c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

actionpack/lib/action_dispatch/routing/mapper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,12 @@ def match(path, *rest)
15711571
options = path
15721572
path, to = options.find { |name, _value| name.is_a?(String) }
15731573

1574+
if path.nil?
1575+
ActiveSupport::Deprecation.warn 'Omitting the route path is deprecated. '\
1576+
'Specify the path with a String or a Symbol instead.'
1577+
path = ''
1578+
end
1579+
15741580
case to
15751581
when Symbol
15761582
options[:action] = to

actionpack/test/dispatch/routing_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ def test_pagemarks
402402
post "create", :as => ""
403403
put "update"
404404
get "remove", :action => :destroy, :as => :remove
405+
tc.assert_deprecated do
406+
get action: :show, as: :show
407+
end
405408
end
406409
end
407410

@@ -420,6 +423,10 @@ def test_pagemarks
420423
get '/pagemark/remove'
421424
assert_equal 'pagemarks#destroy', @response.body
422425
assert_equal '/pagemark/remove', pagemark_remove_path
426+
427+
get '/pagemark'
428+
assert_equal 'pagemarks#show', @response.body
429+
assert_equal '/pagemark', pagemark_show_path
423430
end
424431

425432
def test_admin

0 commit comments

Comments
 (0)