Files didn't get deleted in previous commit. [fixes SCI-1150]

This commit is contained in:
Matej Zrimšek 2017-04-06 10:59:23 +02:00
parent e72184d10d
commit 1447a34dc7

View file

@ -68,7 +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
before_destroy :paperclip_delete, prepend: true
attr_accessor :file_content, :file_info, :preview_cached
@ -239,8 +239,9 @@ class Asset < ActiveRecord::Base
end
end
# Workaround for making Paperclip work with asset deletion
def paperlip_delete
# Workaround for making Paperclip work with asset deletion (might be because
# of how the asset models are implemented)
def paperclip_delete
report_elements.destroy_all
asset_text_datum.destroy if asset_text_datum.present?
# Nullify needed to force paperclip file deletion
@ -248,6 +249,13 @@ class Asset < ActiveRecord::Base
save
end
def destroy
super()
# Needed, otherwise the object isn't deleted, because of how the asset
# models are implemented
delete
end
# If team is provided, its space_taken
# is updated as well
def update_estimated_size(team = nil)