David Badawi
2007-May-27 03:28 UTC
Any way to store instance of ActiveRecord as a string in database
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Badawi
2007-May-27 15:24 UTC
Re: Any way to store instance of ActiveRecord as a string in
thanks shai david On May 27, 3:33 am, shai <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---