Class: TemplateInstantiationValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/template_instantiation_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object


2
3
4
5
6
# File 'app/validators/template_instantiation_validator.rb', line 2

def validate(record)
  if record.template_id && !Ingredient.find(record.template_id).is_template?
    record.errors[:template] << 'Cannot instantiate non-template ingredient'
  end
end