1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Handle either error string or array

This commit is contained in:
Jeremy Kemper 2009-02-06 20:26:24 -08:00
parent 24ac1d6bdc
commit 78c6f48b26

View file

@ -203,7 +203,7 @@ module ActiveResource
def from_xml(xml)
clear
humanized_attributes = @base.attributes.keys.inject({}) { |h, attr_name| h.update(attr_name.humanize => attr_name) }
messages = Hash.from_xml(xml)['errors']['error'] rescue []
messages = Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue []
messages.each do |message|
attr_message = humanized_attributes.keys.detect do |attr_name|
if message[0, attr_name.size + 1] == "#{attr_name} "