Rails3: replace deprecated 'after_destroy' method at Attachment model.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6763 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-08-30 05:08:21 +00:00
parent f28500f1ac
commit 46fb8a8505
1 changed files with 2 additions and 1 deletions

View File

@ -47,6 +47,7 @@ class Attachment < ActiveRecord::Base
@@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files" @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files"
before_save :files_to_final_location before_save :files_to_final_location
after_destroy :delete_from_disk
def validate_max_file_size def validate_max_file_size
if self.filesize > Setting.attachment_max_size.to_i.kilobytes if self.filesize > Setting.attachment_max_size.to_i.kilobytes
@ -96,7 +97,7 @@ class Attachment < ActiveRecord::Base
end end
# Deletes file on the disk # Deletes file on the disk
def after_destroy def delete_from_disk
File.delete(diskfile) if !filename.blank? && File.exist?(diskfile) File.delete(diskfile) if !filename.blank? && File.exist?(diskfile)
end end