]> source.dussan.org Git - redmine.git/commitdiff
Rails3: replace deprecate 'validate' instance method to declared validation method...
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 29 Aug 2011 02:32:18 +0000 (02:32 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 29 Aug 2011 02:32:18 +0000 (02:32 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6714 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/attachment.rb

index e566cb381aeb4fd537ae18d1066534c1cf0bfc9a..792665df8498dce96ac93bda9702298f6bb4b233 100644 (file)
@@ -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