How do I remove the Devise route to sign up?

后端 未结 15 2391
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 07:36

I\'m using Devise in a Rails 3 app, but in this case, a user must be created by an existing user, who determines what permissions he/she will have.

Because of this, I

15条回答
  •  日久生厌
    2020-12-07 08:18

    By changing the routes there are a whole bunch of other problems that come with that. The easiest method I have found is to do the following.

    ApplicationController < ActionController::Base
      before_action :dont_allow_user_self_registration
    
      private
    
      def dont_allow_user_self_registration
        if ['devise/registrations','devise_invitable/registrations'].include?(params[:controller]) && ['new','create'].include?(params[:action])
          redirect_to root_path
        end
      end
    end
    

提交回复
热议问题