From: Kirk Haines Date: 2005-11-18T02:22:49+09:00 Subject: Re: Serializing an instance with arbitrary methods (in rails) On Thursday 17 November 2005 9:21 am, Gavin Kistner wrote: > (I know there's a rails mailing list. For some reason this feels more > appropriate to ruby-talk. I'll go to the other ML if this one fails :) > > Summary: > I'm writing a rails app where I want to save information about a > user's session, so that they may return at a later date and pick up > where they left off. The information being saved is an object with > arbitrary instance variables. What's the best way (or any good way) > to save this? So far, the only thing I can think of is Marshal dump/ > load to a db row, but this seems off for some reason. Is this the > best way? Use Marshal for this. YAML offers similar capabilities, but it is MUCH slower, doesn't handle circular references and such as well, and historically has had bizarre corner cases pop up that broke it. It may be that those corner cases are all resolved, but unless you need a human readable serialization format, use Marshal. Kirk Haines