Class: Refinery::Resources::Validators::FileSizeValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Refinery::Resources::Validators::FileSizeValidator
- Defined in:
- lib/refinery/resources/validators/file_size_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/refinery/resources/validators/file_size_validator.rb', line 6 def validate(record) file = record.file if file.respond_to?(:length) && file.length > Resources.max_file_size record.errors.add :file, ::I18n.t('too_big', scope: 'activerecord.errors.models.refinery/resource', size: Resources.max_file_size) end end |