Class: ActiveModel::Validations::UniquenessOnValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::UniquenessOnValidator
- Defined in:
- lib/active_model/validations/uniqueness_on_validator.rb
Instance Method Summary collapse
Instance Method Details
#filtered_options ⇒ Object
11 12 13 |
# File 'lib/active_model/validations/uniqueness_on_validator.rb', line 11 def .except(:class_name) end |
#validate_each(record, attr_name, value) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/active_model/validations/uniqueness_on_validator.rb', line 4 def validate_each(record, attr_name, value) klass = [:class_name].to_s.camelcase.constantize if klass.exists?(attr_name.to_sym => value) record.errors.add(attr_name, :taken, ) end end |