Class: Concept::SingularRelValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/models/concept.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



137
138
139
140
141
# File 'app/models/concept.rb', line 137

def validate(record)
  [:abstract, :alternative, :restriction, :slug, :source, :schema_image].each do |rel|
    record.errors[rel] << "#{rel} must have 0 or 1 values" unless record.relationships(rel).length < 2
  end
end