# Serializing AR Objects

**URL:** <https://www.ruby-forum.com/t/serializing-ar-objects/137509>\
**Category:** Rails\
**Created:** [May 13, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/serializing-ar-objects/137509 "2008-05-13T20:48:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [May 13, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/serializing-ar-objects/137509/1 "2008-05-13T20:48:21Z")

</div>

I need to serialize a composite AR model and save it to a database  
field.

Reading up on Ruby’s Marshaling, it seems there could be problems  
with the version numbering thing of the default dump/load methods.

As I understand it, Ruby internally marks the serialized data with  
the current Ruby language version, and when loading that data, if the  
major version is changed, the loading is aborted. Seems like a rather  
extreme measure compared to testing a version or formatting of the  
serialized data itself rather than the language version. Or have I  
read this wrong, and these version numbers are for the marshaling  
format and not the whole language?

Considering 1.9 is not too far away (from an application life-cycle  
perspective), this would seem to be a potential big problem.

Is my only option to create custom marshaling methods? That would  
seem to be a rather tedious thing to do for a complex composite  
ActiveRecord object.

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [May 13, 2008, 8:54pm UTC](https://www.ruby-forum.com/t/serializing-ar-objects/137509/2 "2008-05-13T20:54:58Z")

</div>

On May 13, 2008, at 11:47 AM, Greg W. wrote:

> As I understand it, Ruby internally marks the serialized data with  
> the current Ruby language version, and when loading that data, if the  
> major version is changed, the loading is aborted. Seems like a rather  
> extreme measure compared to testing a version or formatting of the  
> serialized data itself rather than the language version. Or have I  
> read this wrong, and these version numbers are for the marshaling  
> format and not the whole language?

DOH! I just now saw one short, buried sentence that clarified that  
marshal versioning is separate from the language versioning. Question  
answered.

– gw
