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

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

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 --> search for serialize.
hth,

shai

thanks shai
david

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs