How to “soft delete” user with Devise

前端 未结 4 1535
北海茫月
北海茫月 2020-12-07 07:25

I currently use Devise for user registration/authentication in a Rails project. When a user wants to cancel their account, the user object is destroyed, which leaves my appl

4条回答
  •  孤街浪徒
    2020-12-07 08:15

    A complete tutorial can be found at Soft Delete a Devise User Account on the Devise wiki page.

    Summary:
    1. Add a "deleted_at" DATETIME column
    2. Override users/registrations#destroy in your routes
    3. Override users/registrations#destroy in the registrations controller
    4. Update user model with a soft_delete & check if user is active on authentication
    5. Add a custom delete message

提交回复
热议问题