DEV: Added .only_deleted scope in the Trashable module (#20196)

This commit is contained in:
Sérgio Saquetim
2023-02-07 15:28:59 -03:00
committed by GitHub
parent 6e522e4aad
commit 5d32db76dd
2 changed files with 17 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ module Trashable
included do
default_scope { where(deleted_at: nil) }
scope :with_deleted, -> { unscope(where: :deleted_at) }
scope :only_deleted, -> { with_deleted.where.not(deleted_at: nil) }
belongs_to :deleted_by, class_name: "User"
end