[LRUG] Best way to serialise a Ruby object?

Jonathan del Strother maillist at steelskies.com
Thu Jul 14 02:19:40 PDT 2011


Marshal.dump would be the obvious choice.  Just make sure you're
either storing it as binary or converting to base64 first, to avoid
interesting encoding/decoding problems in mysql.

On 14 July 2011 10:11, Andrew Stewart <boss at airbladesoftware.com> wrote:
> Hola El Rug,
>
> What's the best way these days to serialise a Ruby object for storage in a SQL database field, and de-serialise it back again?
>
> To date I've been using YAML but I've run across a situation where the YAML written by Ruby can't be de-serialised again (due, I think, to Sych versus Psych).
>
> Should I be switching to something other than YAML?
>
> Cheers,
> Andy Stewart
>
> -------
> http://airbladesoftware.com
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>



More information about the Chat mailing list