When we try to deserialize a Model from our database we always receive a YAML object. For that we added the following code in the environment.rb:
YAML.add_domain_type("ActiveRecord,2007", "") do |type, val|
klass = type.split(":").last.constantize
YAML.object_maker(klass, val)
end
class ActiveRecord::Base
def to_yaml_type
"!ActiveRecord,2007/#{self.class}"
end
end
class ActiveRecord::Base
def to_yaml_properties
['@attributes']
end
end
This works! But only once, when I refresh the screen I always undefined method ... for YAML
. It seems like my code isn't executed anymore...
Can anyone help?
Thnx!