reconstructing ActiveRecord from YAML

Frantisek Psotka wrote:

hello, please give me snipped, that reconstruct ActiveRecord object from YAML or Marshal.dump. When i type for example: YAML::load(item.to_yaml), the returned object is not (item's class) Item. When i use: Marshal::load(Marshal::dump item), it throws exception "undefined class/module Item" How can I do this? Thanx.

At a guess, a model's attributes member is very Hash-like, and Hashes are also a native YAML type. So you _might_ store it with yaml_string = model.attributes.to_yaml , and load that with model.attributes = YAML::load(yaml_string).