diff options
author | Volmer <git@radicaos.com> | 2016-07-04 21:58:20 -0400 |
---|---|---|
committer | Volmer <git@radicaos.com> | 2016-07-05 11:16:54 -0400 |
commit | 1fd9cdfda6c4e4473667cb6e28b8097607abc765 (patch) | |
tree | f4446bccd23db8232bf248e6f3c3a75a9b8d856c /actionpack/lib/action_dispatch | |
parent | 9552f8b457a674c66f99d6cbef244fbb7de6ba34 (diff) | |
download | rails-1fd9cdfda6c4e4473667cb6e28b8097607abc765.tar.gz rails-1fd9cdfda6c4e4473667cb6e28b8097607abc765.tar.bz2 rails-1fd9cdfda6c4e4473667cb6e28b8097607abc765.zip |
Deprecate usage of nil as route path
In Rails 4 these kind of routes used to work:
```ruby
scope '/*id', controller: :builds, as: :build do
get action: :show
end
```
But since 1a830cbd830c7f80936dff7e3c8b26f60dcc371d, routes are only created for
paths specified as strings or symbols. Implicit `nil` paths are just ignored,
with no deprecation warnings or errors. Routes are simply not created. This come
as a surprise for people migrating to Rails 5, since the lack of logs or errors
makes hard to understand where the problem is.
This commit introduces a deprecation warning in case of path as `nil`, while
still allowing the route definition.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index e2cf75da3a..73b4864e45 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1562,6 +1562,12 @@ module ActionDispatch options = path path, to = options.find { |name, _value| name.is_a?(String) } + if path.nil? + ActiveSupport::Deprecation.warn 'Omitting the route path is deprecated. '\ + 'Specify the path with a String or a Symbol instead.' + path = '' + end + case to when Symbol options[:action] = to |