Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

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

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 < Devise::RegistrationsController

    protected

    def after_inactive_sign_up_path_for(resource)
        '/sign_up/inactive'
    end
end

routes.rb

root :to => 'home#index'
devise_for :users
resources :users

devise_for :users, :controllers => { :registrations => "registrations" }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...