Skip to content

Commit

Permalink
Handle either error string or array
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Feb 7, 2009
1 parent 24ac1d6 commit 78c6f48
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activeresource/lib/active_resource/validations.rb
Expand Up @@ -203,7 +203,7 @@ def size
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} "
Expand Down

0 comments on commit 78c6f48

Please sign in to comment.