# Is there a way to save an object to disk?

**URL:** <https://www.ruby-forum.com/t/is-there-a-way-to-save-an-object-to-disk/73241>\
**Category:** Rails\
**Created:** [October 23, 2006, 6:03am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-save-an-object-to-disk/73241 "2006-10-23T06:03:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveeq1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@steveeq1](https://www.ruby-forum.com/u/steveeq1)\
**Post date:** [October 23, 2006, 6:03am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-save-an-object-to-disk/73241/1 "2006-10-23T06:03:31Z")

</div>

I am new to ruby so pardon my naive question, but:

Is there an easy way to save the contents of an object to disk? Is there  
an easy way to read it back?

You don’t have to spell it out for me, I just need the general idea of  
how to do it.

---

<div class="post-metadata">

**Author:** ![steveeq1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@steveeq1](https://www.ruby-forum.com/u/steveeq1)\
**Post date:** [October 23, 2006, 7:52am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-save-an-object-to-disk/73241/2 "2006-10-23T07:52:49Z")

</div>

On 23 Oct 2006, at 05:03, Steve Q. wrote:

> Is there an easy way to save the contents of an object to disk? Is  
> there  
> an easy way to read it back?
> 
> You don’t have to spell it out for me, I just need the general idea of  
> how to do it.

Start here:

[http://www.ruby-doc.org/core/classes/Marshal.html](http://www.ruby-doc.org/core/classes/Marshal.html)

See? Got the juices flowing? HTH,

–  
Paul R.  
[http://vagueware.com](http://vagueware.com)

---

<div class="post-metadata">

**Author:** ![steveeq1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@steveeq1](https://www.ruby-forum.com/u/steveeq1)\
**Post date:** [October 23, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/is-there-a-way-to-save-an-object-to-disk/73241/3 "2006-10-23T14:18:18Z")

</div>

Or, if you want a human-readable (text) format, try YAML (require  
‘yaml’).

best wishes  
Huw C.

[http://www.sapphiresteel.com](http://www.sapphiresteel.com)  
Ruby P.ming In Visual Studio 2005

---

<div class="post-metadata">

**Author:** ![steveeq1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@steveeq1](https://www.ruby-forum.com/u/steveeq1)\
**Post date:** [October 24, 2006, 12:15am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-save-an-object-to-disk/73241/4 "2006-10-24T00:15:10Z")

</div>

Steve Q. wrote:

> I am new to ruby so pardon my naive question, but:
> 
> Is there an easy way to save the contents of an object to disk? Is there  
> an easy way to read it back?
> 
> You don’t have to spell it out for me, I just need the general idea of  
> how to do it.

Your question inspired me to a blog post on the subject…

Check it out here:  
[http://rails.co.za/articles/2006/10/23/saving-ruby-objects-to-disc](http://rails.co.za/articles/2006/10/23/saving-ruby-objects-to-disc)

Cheery-o  
Gustav P.  
removed\_email\_address@domain.invalid
