How To: Disable user from destroying their account alternative method - heartcombo/devise GitHub Wiki
How To: Disable user from destroying their account describes a way to disable users from destroying their accounts by redefining routes for the registrations controller.
You can also achieve a similar result by overriding the paths in config/routes.rb
. Here we take advantage of the fact that the routes.rb
file is read from top to bottom, and will use the first matching route. Below, I am routing to the Rack application contained in the lambda.
config/routes.rb
delete '/users', to: ->(env) { [404, {}, ['']] }
devise_for :users
You can use this method to disable any other routes in Devise.
One drawback of this method is that the original route will still show up in bin/rails routes
but if this does not bother you, then I think this is a simpler way to disable routes.