升级到 Rails 4 后,带有前缀名称和斜杠的路由会引发错误。
actionpack-4.0.1.rc1/lib/action_dispatch/routing/mapper.rb:239:in `default_controller_and_action':
'MyEngine/dashboard'
is not a supported controller name. This can lead to potential routing problems.
在 routes.rb 我有
Rails.application.routes.draw do
mount MyEngine::Engine => "/foo", :as => 'my_engine'
match 'dashboard' => 'MyEngine/dashboard', via: :get
在已安装的引擎 MyEngine 中:
MyEngine::Engine.routes.draw do
match 'dashboard' => 'dashboard#index', via: :get
这在 Rails 3.2 中运行良好,但在 Rails 4 中,“MyEngine/dashboard”中的斜线会引发错误。