Rails - How To Destroy Users Created Under Devise?

后端 未结 5 1481
北海茫月
北海茫月 2020-12-15 07:13

For my application, I have user accounts that people can sign up. I use the devise gem for the setup.

I also have a users page that lists out all the u

5条回答
  •  遥遥无期
    2020-12-15 07:31

    At least the latest version of Devise does provide such functionality out of the box, if a Devise-backed model has :registerable included.

    class User < ApplicationRecord
      devise :database_authenticatable, :registerable
    end
    

    Somewhere in app/views/layouts/application.html.erb:

    <%= link_to 'Delete my account', user_registration_path, method: :delete if user_signed_in? %>
    

提交回复
热议问题