Method: SetValidator#validate_each
- Defined in:
- lib/lanes/validators/set.rb
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lanes/validators/set.rb', line 6 def validate_each( record, attribute, value) association = record.class.reflect_on_association( attribute ) if association.nil? || !association.belongs_to? raise ArgumentError, "Cannot validate existence on #{record.class} #{attribute}, not a :belongs_to association" end if record.send( attribute ).nil? record.errors.add( attribute, "is not set") end end |