Fixed so that file deletion callbacks are triggered (and hence audit trails for this is generated). [fixes SCI-1150]

This commit is contained in:
Matej Zrimšek 2017-03-31 13:26:37 +02:00
parent 4855111dcb
commit e72184d10d

View file

@ -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