mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-08 16:40:16 +08:00
Fixed so that file deletion callbacks are triggered (and hence audit trails for this is generated). [fixes SCI-1150]
This commit is contained in:
parent
4855111dcb
commit
e72184d10d
1 changed files with 3 additions and 3 deletions
|
@ -68,6 +68,7 @@ class Asset < ActiveRecord::Base
|
||||||
after_validation :filter_paperclip_errors
|
after_validation :filter_paperclip_errors
|
||||||
# Needed because Paperclip validatates on creation
|
# Needed because Paperclip validatates on creation
|
||||||
after_initialize :filter_paperclip_errors, if: :new_record?
|
after_initialize :filter_paperclip_errors, if: :new_record?
|
||||||
|
before_destroy :paperlip_delete, prepend: true
|
||||||
|
|
||||||
attr_accessor :file_content, :file_info, :preview_cached
|
attr_accessor :file_content, :file_info, :preview_cached
|
||||||
|
|
||||||
|
@ -238,14 +239,13 @@ class Asset < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
# Workaround for making Paperclip work with asset deletion
|
||||||
|
def paperlip_delete
|
||||||
report_elements.destroy_all
|
report_elements.destroy_all
|
||||||
asset_text_datum.destroy if asset_text_datum.present?
|
asset_text_datum.destroy if asset_text_datum.present?
|
||||||
|
|
||||||
# Nullify needed to force paperclip file deletion
|
# Nullify needed to force paperclip file deletion
|
||||||
self.file = nil
|
self.file = nil
|
||||||
save
|
save
|
||||||
delete
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# If team is provided, its space_taken
|
# If team is provided, its space_taken
|
||||||
|
|
Loading…
Reference in a new issue