# Any way to store instance of ActiveRecord as a string in dat

**URL:** <https://www.ruby-forum.com/t/any-way-to-store-instance-of-activerecord-as-a-string-in-dat/105206>\
**Category:** Rails\
**Created:** [May 27, 2007, 5:29am UTC](https://www.ruby-forum.com/t/any-way-to-store-instance-of-activerecord-as-a-string-in-dat/105206 "2007-05-27T05:29:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Badawi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@David\_Badawi](https://www.ruby-forum.com/u/David_Badawi)\
**Post date:** [May 27, 2007, 5:29am UTC](https://www.ruby-forum.com/t/any-way-to-store-instance-of-activerecord-as-a-string-in-dat/105206/1 "2007-05-27T05:29:20Z")

</div>

Greetings,  
I was wondering if any one had a suggestion for how I should approach  
a problem:

I am interested in storing an instance of ActiveRecord as a string in  
a database and reconstituting or converting it back into ActiveRecord  
at a later time-basically capturing the object in a database, but not  
as a database row in the traditional sense.

I can do this by storing the attributes of the instance in the  
database and later iterating through them, but I was hoping that I  
could basically serialize the entire object, store it in the db, and  
recall it later to reap the benefits of ActiveRecord.

Thanks in advance.

David

---

<div class="post-metadata">

**Author:** ![David\_Badawi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@David\_Badawi](https://www.ruby-forum.com/u/David_Badawi)\
**Post date:** [May 27, 2007, 10:33am UTC](https://www.ruby-forum.com/t/any-way-to-store-instance-of-activerecord-as-a-string-in-dat/105206/2 "2007-05-27T10:33:47Z")

</div>

then use serialize.  
hmm.

Saving arrays, hashes, and other non-mappable objects in text columns:

“Active Record can serialize any object in text columns using YAML. To  
do so, you must specify this with a call to the class method serialize.  
This makes it possible to store arrays, hashes, and other non-mappable  
objects without doing any additional work.”

taken from [api.rubyonrails.com](http://api.rubyonrails.com) → search for serialize.  
hth,

shai

---

<div class="post-metadata">

**Author:** ![David\_Badawi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@David\_Badawi](https://www.ruby-forum.com/u/David_Badawi)\
**Post date:** [May 27, 2007, 5:25pm UTC](https://www.ruby-forum.com/t/any-way-to-store-instance-of-activerecord-as-a-string-in-dat/105206/3 "2007-05-27T17:25:29Z")

</div>

thanks shai  
david
