class HerExtension::Validations::RemoteUniquenessValidator
Validate the uniqueness of a field by performing a remote API call
Public Instance Methods
validate_each(record,attribute,value)
click to toggle source
# File lib/her_extension/validations/remote_uniqueness_validation.rb, line 9 def validate_each(record,attribute,value) list = record.class.where({ attribute => value }).limit(1) if list.reject { |e| e.id == record.id }.any? error_options = options.except(:case_sensitive, :scope, :conditions) error_options[:value] = value record.errors.add(attribute, :taken, error_options) end end