soft-destroyable
Installation
SKILL.md
Soft Destroyable
app/models/concerns/soft_destroyable.rb marks records deleted by setting a deleted_at timestamp instead of removing rows. If the concern isn't there, run bin/rails g rolemodel:soft_destroyable.
Making a model soft-destroyable
- Add a nullable
deleted_atdatetime column (the generator doesn't add one). - Include the concern, and cascade to any associations that should go and come back with the parent:
class Estimate < ApplicationRecord
include SoftDestroyable
has_many :line_items
cascade_soft_destroy :line_items # each associated model must also include SoftDestroyable
end