我使用导轨4.1.1和ruby2.1.1,我有一个设计问题,即我的路线.我已经使用了这么多次
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
但我得到错误
`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
所以我改变了我的认证的根到帮手像这样
# Directing the user after login authenticated :user do root :to => 'pages#index',as: :authenticated_root end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。