How to Remove/Disable Sign Up From Devise

前端 未结 6 1276
余生分开走
余生分开走 2021-02-05 02:56

I\'m trying to remove/disable the user/sign_up path from Devise. I\'m doing this because I don\'t want random people gaining access to the application. I have it p

6条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 03:13

    Below code seem to do the trick for me:

    Rails.application.routes.draw do
    
      devise_scope :users do #notice "users" here, not "user"
        get "/sign_in" => "devise/sessions#new" # custom path to login/sign_in
        get "/sign_up" => "devise/registrations#new", as: "new_user_registration" # custom path to sign_up/registration
      end
    
      devise_for :users, :skip => [:registrations]
      as :user do
        get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'
        put 'users' => 'devise/registrations#update', :as => 'user_registration'
      end
    ...
    

提交回复
热议问题