views:

1268

answers:

1

I am trying to deserialize an object from xml in ruby. Something simple like

u = User.new({:client_key => "Bar"})
v = User.new(u.to_xml)

I get an error NoMethodError: undefined method `stringify_keys!' for #String:0x20fc7cc>. I'm not sure what I have to do in order to get the string from xml to an object.

Update:
@avdi gave me the tip. I was expecting from_xml to be a self method. You have to create the object first.

v = User.new
v.from_xml(s)
+4  A: 

A quick search turns up http://api.rubyonrails.org/classes/ActiveRecord/Serialization.html#M001420

Avdi