Sha256: 29a88d84534ad2e0c8f83b4d03516ea52f8c7a1a8b1137f6e19723062963ff15
Contents?: true
Size: 895 Bytes
Versions: 3
Compression:
Stored size: 895 Bytes
Contents
module Paperclip module PermanentRecords module ActiveRecord extend ActiveSupport::Concern def destroy(force = nil) if paperclip_attachments? && # only when we have paperclip attachments, (!is_permanent? || # if model does not support "safe deletion" ::PermanentRecords.should_force_destroy?(force)) # or if model supports "safe deletion" but it is forced schedule_attachments_for_deletion # => delete the attachments end super(force) end private def paperclip_attachments? self.class.respond_to?(:attachment_definitions) end # (this contains what each of the before_destroy callbacks originally did) def schedule_attachments_for_deletion self.class.attachment_definitions.each_key { |name| send(name).send(:queue_all_for_delete) } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems