From e72184d10dfd5d1c68beea7598e89e2b9f3676ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Zrim=C5=A1ek?= Date: Fri, 31 Mar 2017 13:26:37 +0200 Subject: [PATCH] Fixed so that file deletion callbacks are triggered (and hence audit trails for this is generated). [fixes SCI-1150] --- app/models/asset.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/asset.rb b/app/models/asset.rb index f31358cef..9af189c9c 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -68,6 +68,7 @@ class Asset < ActiveRecord::Base after_validation :filter_paperclip_errors # Needed because Paperclip validatates on creation after_initialize :filter_paperclip_errors, if: :new_record? + before_destroy :paperlip_delete, prepend: true attr_accessor :file_content, :file_info, :preview_cached @@ -238,14 +239,13 @@ class Asset < ActiveRecord::Base end end - def destroy + # Workaround for making Paperclip work with asset deletion + def paperlip_delete report_elements.destroy_all asset_text_datum.destroy if asset_text_datum.present? - # Nullify needed to force paperclip file deletion self.file = nil save - delete end # If team is provided, its space_taken