add trashable concern on user

This commit is contained in:
João Geonizeli
2022-07-31 21:17:22 -03:00
parent 4a2d2d1a67
commit eff96cd102
10 changed files with 221 additions and 168 deletions

View File

@@ -0,0 +1,21 @@
module Trashable
extend ActiveSupport::Concern
included do
default_scope { where(deleted_at: nil) }
end
module ClassMethods
def trashed
self.unscoped.where(self.arel_table[:deleted_at].not_eq(nil))
end
end
def destroy
update_column :deleted_at, Time.now
end
def recover
update_attribute :deleted_at, nil
end
end