开发者

How to store hash in session in Ruby

开发者 https://www.devze.com 2023-02-23 13:51 出处:网络
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 tha

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

精彩评论

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