How to “soft delete” user with Devise

前端 未结 4 1529
北海茫月
北海茫月 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:05

    Adding onto hakunin's answer:

    To prevent "soft deleted" users from signing in, override active_for_authentication? on your User model:

    def active_for_authentication?
      super && !deleted_at
    end
    

提交回复
热议问题