lib/devise/multi_email/models/validatable.rb in devise-multi_email-3.0.0 vs lib/devise/multi_email/models/validatable.rb in devise-multi_email-3.0.1
- old
+ new
@@ -64,11 +64,11 @@
private
def propagate_email_errors
association_name = self.class.multi_email_association.name
- email_error_key = errors.keys.detect do |key|
+ email_error_key = errors_attribute_names.detect do |key|
[association_name.to_s, "#{association_name}.email"].include?(key.to_s)
end
return unless email_error_key.present?
email_errors =
@@ -82,9 +82,13 @@
end
email_errors.each do |type, message|
errors.add(:email, type, message: message)
end
+ end
+
+ def errors_attribute_names
+ errors.respond_to?(:attribute_names) ? errors.attribute_names : errors.keys
end
module ClassMethods
# All validations used by this module.