diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-08-29 02:32:18 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-08-29 02:32:18 +0000 |
commit | af7ec57f15005c22dac7402f979223a95c7802e1 (patch) | |
tree | 31dbb5aaf91c1d11e4152d13e0090a0abe2844b5 /app | |
parent | 94f7b0ea16d138566ac5e9f7d375a9e0ba2c9e91 (diff) | |
download | redmine-af7ec57f15005c22dac7402f979223a95c7802e1.tar.gz redmine-af7ec57f15005c22dac7402f979223a95c7802e1.zip |
Rails3: replace deprecate 'validate' instance method to declared validation method at Attachment model.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6714 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/attachment.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb index e566cb381..792665df8 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -24,6 +24,7 @@ class Attachment < ActiveRecord::Base validates_presence_of :container, :filename, :author validates_length_of :filename, :maximum => 255 validates_length_of :disk_filename, :maximum => 255 + validate :validate_max_file_size acts_as_event :title => :filename, :url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}} @@ -45,7 +46,7 @@ class Attachment < ActiveRecord::Base cattr_accessor :storage_path @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files" - def validate + 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) end |