Question

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)
Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top