Rails 4 + Devise: Invalid route name, already in use

匿名 (未验证) 提交于 2019-12-03 01:59:02

问题:

I'm following this how-to to modify the confirmation page after a successful sign up.

https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)

I do everything like it says but i get this error:

in `add_route': Invalid route name, already in use: 'new_user_session'  (ArgumentError) You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:  http://guides.rubyonrails.org/routing.html#restricting-the-routes-created 

I guess the wiki is not updated for using Devise with Rails 4, but i don't find around enough information to fix the error.

The line which is returning the error is next (routes.rb):

devise_for :users, :controllers => { :registrations => "registrations" } 

Any suggestion?

Thanks.

EDIT --

registrations_controller.rb

class RegistrationsController 

routes.rb

root :to => 'home#index' devise_for :users resources :users  devise_for :users, :controllers => { :registrations => "registrations" } 

回答1:

You have two routes devise_for :users in your routes.rb - remove the first one.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!