Class: Relations::RelationValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/concerns/relations.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



10
11
12
# File 'lib/concerns/relations.rb', line 10

def validate_each(record, attribute, value)
  record.errors.add(attribute, "#{attribute} or #{attribute}_id is required") unless record.try(attribute).present? || record.try("#{attribute}_id".to_sym).present?
end