Skip to content

How To: Disable user from destroying their account

Eduardo de Santana Medeiros Alexandre edited this page Dec 28, 2017 · 1 revision

To disable users from destroying their accounts just redefine routes for registrations controller without route to destroy action, so for example:

devise_for :users, skip: :registrations
devise_scope :user do
  resource :registration,
    only: [:new, :create, :edit, :update],
    path: 'users',
    path_names: { new: 'sign_up' },
    controller: 'devise/registrations',
    as: :user_registration do
      get :cancel
    end
end

For more details see devise_registration method from lib/devise/rails/routes.rb.

Clone this wiki locally