Deserialization error while loading ActiveRecord objects from YAML

Why am I getting this error when I try to deserialize a new ActiveRecord object:

[Dev]> YAML.load(Identity.new.to_yaml)
Delayed::DeserializationError: Delayed::DeserializationError

while this example with an existing AR object works as expected:

[Dev]> YAML.load(Identity.first.to_yaml)
=> #<Identity id: 1, ...

A few things that seem relevant are based on finding answers:

I use the ruby 1.9.2p318, rails 3.1.3, delayed_job 2.1.4, and my YAML::ENGINE.yamler- syck.

What can I do so that I can serialize the new Identity record as YAML and then deserialize it later?

UPDATE: I also found that if I remove the stone delayed_job, then this simple example will work, and mine YAML::ENGINE.yamlernow psych. But I use delayed_jobin my application, so it’s still important to understand what is happening

+5
1

, , delayed_job, serialization/active_record.rb

Ruby syck ( syck ) YAML define yaml_new , YAML.load, , id,

YAML.load(Identity.first.to_yaml)

Identity.find(1)

Identity.new, no id ,

, , , , - , .

Delayed::DeserializationError: Delayed::DeserializationError

, no primary ,

, , this commit possible, , , , , ,

ActiveRecord::RecordNotFound, class: #{klass} , primary key: #{val['attributes'][klass.primary_key]} 

:

syck pysch, , , . ,

+3

All Articles