Reputation: 5638
I'm looking for a way to serialize a hash so it can be stored in a Sinatra flash session. Does anyone have any idea? Thanks.
Upvotes: 2
Views: 2733
Reputation: 5342
Might want to read this for ideas:
http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/
Personally, I use json for most of my client-facing objects that come from ruby.
Upvotes: 1
Reputation: 303271
Serialize your Hash to a JSON or YAML string and store that. This assumes that you don't have anything crazy in your Hash like a lambda or a Thread that cannot be serialized.
Upvotes: 4