开发者

How to store hash in session in Ruby

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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜