lib/api-client/errors.rb in api-client-1.5.3 vs lib/api-client/errors.rb in api-client-1.5.4
- old
+ new
@@ -4,12 +4,12 @@
class ApiClient::Errors < ActiveModel::Errors
# Add serveral errors from a hash to the object.
#
# @return [ApiClient::Errors] The Error object.
def add_errors(errors = {})
- errors.each do |key, value|
- self.set(key, value)
+ errors.each_pair do |key, value|
+ add(key, value)
end
end
# Returns a unique message for each array of error messages in a hash.
#
@@ -37,8 +37,8 @@
# person = Person.create(address: '123 First St.')
# person.errors.unique_message(:name) # => "is too short (minimum is 5 characters) and can't be blank"
# person.errors.unique_message(:address) # => nil
def unique_message(attribute)
return '' if messages[attribute].blank?
- messages[attribute].to_sentence
+ [messages[attribute]].flatten.to_sentence
end
end