##// END OF EJS Templates
Rails3: replace deprecated 'after_destroy' method at Attachment model....
Toshi MARUYAMA -
r6643:46fb8a850551
parent child
Show More
@@ -47,6 +47,7 class Attachment < ActiveRecord::Base
47 @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files"
47 @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files"
48
48
49 before_save :files_to_final_location
49 before_save :files_to_final_location
50 after_destroy :delete_from_disk
50
51
51 def validate_max_file_size
52 def validate_max_file_size
52 if self.filesize > Setting.attachment_max_size.to_i.kilobytes
53 if self.filesize > Setting.attachment_max_size.to_i.kilobytes
@@ -96,7 +97,7 class Attachment < ActiveRecord::Base
96 end
97 end
97
98
98 # Deletes file on the disk
99 # Deletes file on the disk
99 def after_destroy
100 def delete_from_disk
100 File.delete(diskfile) if !filename.blank? && File.exist?(diskfile)
101 File.delete(diskfile) if !filename.blank? && File.exist?(diskfile)
101 end
102 end
102
103
General Comments 0
You need to be logged in to leave comments. Login now