Class: ActiveModel::Validations::AttachedValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/active_model/validations/attached_validator.rb

Overview

Validates that a file is attached

Example:

validates :logo, attached: true

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



12
13
14
# File 'lib/active_model/validations/attached_validator.rb', line 12

def validate_each(record, attribute, value)
  record.errors.add(attribute, options[:message] || "must be attached") unless value.attached?
end