Class: MustBeAValueValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- MustBeAValueValidator
- Defined in:
- lib/app/validators/must_be_a_value_validator.rb
Overview
usage:
in your model, add:
validates :sex, :must_be_a_value => true;
this checks against the objects attribute_values
Instance Method Summary collapse
Instance Method Details
#error_message ⇒ Object
8 9 10 |
# File 'lib/app/validators/must_be_a_value_validator.rb', line 8 def "is geen geldige keuze." end |
#help_message ⇒ Object
12 13 14 |
# File 'lib/app/validators/must_be_a_value_validator.rb', line 12 def "U dient een keuze te maken." end |
#validate_each(record, attribute, value) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/app/validators/must_be_a_value_validator.rb', line 16 def validate_each(record, attribute, value) values = attribute_values(record, attribute) if values.assoc(value).nil? record.errors[attribute] << ([:message] || ) end end |