Skip to main content

Keep Files

The keep_files plugin prevents the attached file (and any of its derivatives) from being deleted when the attachment would normally be destroyed, which happens when the attachment is removed/replaced, or when the record is deleted. This functionality is useful when implementing soft deletes, versioning, or in general any scenario where you need to keep history.

plugin :keep_files
photo.image #=> #<Shrine::UploadedFile>
photo.destroy
photo.image.exists? #=> true