我使用导轨4.1.1和ruby2.1.1,我有一个设计问题,即我的路线.我已经使用了这么多次
@H_403_2@devise_for :users
get 'pages/index'
# Route to Devise Login Page
devise_scope :user do
root to: "devise/sessions#new"
end
# Directing the user after login
authenticated :user do
root :to => 'pages#index'
end
但我得到错误
@H_403_2@`add_route': Invalid route name,already in use: 'root' (ArgumentError)当尝试启动服务器..我可以看到,根被使用了两次,但像我说我已经能够做到这一点在过去..有没有办法
谢谢
解决方法
在stackoverflow上发现这个有用的评论
For Rails 4.0 you have to make sure you have unique names for the path
helpers,like root to: “dashboard#show”,as: :authenticated_root.
Otherwise the authenticated root and the normal root route end up
having the same name for their path helpers,which Rails 4.0 no longer
allows
所以我改变了我的认证的根到帮手像这样
@H_403_2@# Directing the user after login authenticated :user do root :to => 'pages#index',as: :authenticated_root end