I’m serializing a ruby object with
YAML::dump(obj)
and storing it in a database.
Then I’m calling
myobj = YAML::load(obj)
I can see in debug that the object was succesfully created and it’s fields were initialized.
But when I’m trying to call an attribute, for example “name” like myobj.name, I recieve a “no method error” message. What am I doing wrong, and how can I correctly deserialize the object?BTW I can access fields of my object by calling
myobj.instance_variable_get('@attributes')[:name]
Thanks.
Are you sure your object has a method
name?Can you try a
Just to be sure, the object you store has really a method
name.Your
doesn’t indicate, that there is a method or attribute
name. There is only an attribute@attributes, that supports a method[](probably a hash).Perhaps you can use
But without more information, all this are only a guess.