PostgreSQL check whether timestamp field is empty

后端 未结 1 1866
無奈伤痛
無奈伤痛 2021-01-06 13:11

I followed these instructions to check whether a user has been soft-deleted or not when logging in. In the example below I can check for a boolean value:

Cla         


        
相关标签:
1条回答
  • 2021-01-06 13:29

    You can't using this solution, without modifying devise of course. Devise will send your conditions directly to the database, so no way of calling a method or using a library like squeel (that will allow something like where{created_at == nil}.

    You could use the solution provided in How to "soft delete" user with Devise, but the error message will be: "You have to confirm your account before continuing."

    Add this to your resource model:

      def inactive_message
        !!deleted_at ? :deleted : super
      end
    

    And add a message to your locales:

    en:
      devise:
        failure:
          deleted: "Your account was deleted."
    

    I hope it helps!

    0 讨论(0)
提交回复
热议问题