summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-08-30 04:11:48 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-08-30 04:11:48 +0000
commit9f5a6a29544cdf4cb98a1e7fa07f188044ff20f3 (patch)
treef5169c6cd0f4a7d1588d317d75a64ffe2e6bf696 /app
parent328cadc4d39e6744494e154fcb68ab8e8fc7bdee (diff)
downloadredmine-9f5a6a29544cdf4cb98a1e7fa07f188044ff20f3.tar.gz
redmine-9f5a6a29544cdf4cb98a1e7fa07f188044ff20f3.zip
Rails3: replace deprecated 'before_save' method at Attachment model.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6756 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/attachment.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 792665df8..675d33fb5 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -46,6 +46,8 @@ class Attachment < ActiveRecord::Base
cattr_accessor :storage_path
@@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files"
+ before_save :files_to_final_location
+
def validate_max_file_size
if self.filesize > Setting.attachment_max_size.to_i.kilobytes
errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes)
@@ -73,7 +75,7 @@ class Attachment < ActiveRecord::Base
# Copies the temporary file to its final location
# and computes its MD5 hash
- def before_save
+ def files_to_final_location
if @temp_file && (@temp_file.size > 0)
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
md5 = Digest::MD5.new