Class: NoSuchIngredientValidator

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

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object


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

def validate(record)
  unless Ingredient.exists?(record.target_id)
    record.errors[:no_such_target] = 'The specified target ingredient does not exist!'
  end
end