3

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)
1
  • This is a Rails/ActiveRecord question, not a Ruby question (to_xml is not part of Ruby). Re-tagged accordingly. Commented Oct 28, 2008 at 19:48

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.