How to Remove/Disable Sign Up From Devise

前端 未结 6 1307
余生分开走
余生分开走 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:14

    I just had the same issue. My solution is a mix of these answers.

    1. Comment out or remove :registerable in user.rb:
    class User < ActiveRecord::Base
      devise :database_authenticatable, #:registerable,
             :recoverable, :rememberable, :trackable, :validatable
    end
    
    1. Remove the registration paths from devise_for in routes.rb:
    devise_for :users, :skip => [:registrations], controllers: {
      sessions: 'users/sessions'
    }
    

    Now Devise will skip all of the registration links from their view and also you no longer have the registration paths on your routes.

提交回复
热议问题