Class: Papercat::UniquenessValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Papercat::UniquenessValidator
- Defined in:
- lib/papercat/uniqueness_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
3 4 5 6 |
# File 'lib/papercat/uniqueness_validator.rb', line 3 def validate(record) found = record.class.get([:key] => record.public_send([:key])).first record.errors.add [:key], :taken if found && found.id != record.id end |