@@ -24,6 +24,7 class Attachment < ActiveRecord::Base | |||
|
24 | 24 | validates_presence_of :container, :filename, :author |
|
25 | 25 | validates_length_of :filename, :maximum => 255 |
|
26 | 26 | validates_length_of :disk_filename, :maximum => 255 |
|
27 | validate :validate_max_file_size | |
|
27 | 28 | |
|
28 | 29 | acts_as_event :title => :filename, |
|
29 | 30 | :url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}} |
@@ -45,7 +46,7 class Attachment < ActiveRecord::Base | |||
|
45 | 46 | cattr_accessor :storage_path |
|
46 | 47 | @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files" |
|
47 | 48 | |
|
48 | def validate | |
|
49 | def validate_max_file_size | |
|
49 | 50 | if self.filesize > Setting.attachment_max_size.to_i.kilobytes |
|
50 | 51 | errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes) |
|
51 | 52 | end |
General Comments 0
You need to be logged in to leave comments.
Login now