How to change the login and signup urls in devise plugin Rails

前端 未结 6 2296
失恋的感觉
失恋的感觉 2020-12-13 02:29

I am using devise plugin in my new Rails App. My issue is devise plugin has default roots for login and signup

/users/sign_in
/users/sign_up
<
6条回答
  •  抹茶落季
    2020-12-13 03:25

    I was able to fix my issue by using the following code in my routes

      devise_for :users,
               :controllers => { :sessions => 'devise/sessions'},
               :skip => [:sessions] do
        get '/login'   => "devise/sessions#new",       :as => :new_user_session
        post '/login'  => 'devise/sessions#create',    :as => :user_session
        get '/signout'  => 'devise/sessions#destroy',   :as => :destroy_user_session
        get "/signup" => "devise/registrations#new", :as => :new_user_registration
      end
    

    But still in my views if I use

      link_to "Register", new_user_registration_path
    

    In my browser its showing as

      /user/sign_up   and not as /signup
    

    But if I directly type /signup I will get the registraion page. Is there any mapping I need to do here.

提交回复
热议问题