Skip to content

Instantly share code, notes, and snippets.

@teeparham
teeparham / gist:329698
Created March 11, 2010 21:40
deserialize an array of ActiveRecord objects from xml
module ActiveRecord
class Base
# extends the patch here: http://www.xcombinator.com/2008/08/11/activerecord-from_xml-and-from_json-part-2/
def self.array_from_xml(xml)
hash_array = Hash.from_xml(xml).values.first
hash_array.nil? ? [] : hash_array.collect {|attributes_hash| from_hash(attributes_hash)}
end