Don't validate file size and extension by default.
This commit is contained in:
parent
48c562ebce
commit
1bfbfa1291
|
@ -5,12 +5,4 @@ class Grade < ApplicationRecord
|
|||
validates_numericality_of :grade , :less_than_or_equal_to=>100, :greater_than_or_equal_to=>0, :allow_nil => true
|
||||
validates :lecture, presence: true
|
||||
validates :student, presence: true
|
||||
validate :submission_size_validation
|
||||
|
||||
def submission_size_validation
|
||||
if submission.attached?
|
||||
errors[:grade] << "attachment must be less than 500kB" if submission.blob.byte_size > 500.kilobytes
|
||||
errors[:grade] << "attachment must be a pdf" if submission.filename.extension != "pdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue