Class: UniquenessValidator

Inherits:
ActiveRecord::Validations::UniquenessValidator
  • Object
show all
Defined in:
lib/aform/uniqueness_validator.rb

Overview

tested within integration test

Instance Method Summary collapse

Instance Method Details

#validate_each(form, attribute, value) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/aform/uniqueness_validator.rb', line 4

def validate_each(form, attribute, value)
  object = form.instance_variable_get(:@object)
  @klass = object.class
  super(object, attribute, value).tap do |res|
    form.errors.add(attribute, object.errors.first.last) if object.errors.present?
  end
end