Class: SameProjectAssociationValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/same_project_association_validator.rb

Overview

validates :issue, same_project_association: true end

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



16
17
18
19
20
# File 'app/validators/same_project_association_validator.rb', line 16

def validate_each(record, attribute, value)
  return if record.project == value&.project

  record.errors.add(attribute, 'must associate the same project')
end