@@ -46,7 +46,9 class Attachment < ActiveRecord::Base | |||||
46 | @@storage_path = "#{RAILS_ROOT}/files" |
|
46 | @@storage_path = "#{RAILS_ROOT}/files" | |
47 |
|
47 | |||
48 | def validate |
|
48 | def validate | |
49 |
|
|
49 | 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 | end | |||
50 | end |
|
52 | end | |
51 |
|
53 | |||
52 | def file=(incoming_file) |
|
54 | def file=(incoming_file) |
@@ -48,8 +48,8 protected | |||||
48 | errors.add(:value, :blank) if custom_field.is_required? and value.blank? |
|
48 | errors.add(:value, :blank) if custom_field.is_required? and value.blank? | |
49 | else |
|
49 | else | |
50 | errors.add(:value, :invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) |
|
50 | errors.add(:value, :invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) | |
51 | errors.add(:value, :too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length |
|
51 | errors.add(:value, :too_short, :count => custom_field.min_length) if custom_field.min_length > 0 and value.length < custom_field.min_length | |
52 | errors.add(:value, :too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length |
|
52 | errors.add(:value, :too_long, :count => custom_field.max_length) if custom_field.max_length > 0 and value.length > custom_field.max_length | |
53 |
|
53 | |||
54 | # Format specific validations |
|
54 | # Format specific validations | |
55 | case custom_field.field_format |
|
55 | case custom_field.field_format |
General Comments 0
You need to be logged in to leave comments.
Login now