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