使用ruby在cookie中存储逗号分隔值

时间:2015-06-05 16:51:01

标签: ruby-on-rails cookies

我正在尝试在cookie中保存逗号分隔值,我正在使用ruby on rails。但当我拿到饼干时,我看到了#34;,"转换为%2C。

我不确定我做错了什么,感谢任何帮助。感谢。

以下是我如何保存cookie

cookies[:gridSettings_orders_order] = {:value => "48,78,198,58,98,62,78,118,98,148,128,78,78,178,53,53,43,128,118,43,78,98,148,98|48,78,198,58,98,62,78
,118,98,148,128,78,78,178,53,53,43,128,118,43,78,98,148,98||0,1,4,2,3,5,6,7,8,9,10,11,12,13,14,15,16
,17,18,19,20,21,22,23"} 

但是当我拿到cookie时我得到了

48%2C78%2C198%2C58%2C98%2C62%2C78%2C118%2C98%2C148%2C128%2C78%2C78%2C178%2C53%2C53%2C43%2C128%2C118%2C43
%2C78%2C98%2C148%2C98%7C48%2C78%2C198%2C58%2C98%2C62%2C78%0A%2C118%2C98%2C148%2C128%2C78%2C78%2C178%2C53
%2C53%2C43%2C128%2C118%2C43%2C78%2C98%2C148%2C98%7C%7C0%2C1%2C4%2C2%2C3%2C5%2C6%2C7%2C8%2C9%2C10%2C11
%2C12%2C13%2C14%2C15%2C16%0A%2C17%2C18%2C19%2C20%2C21%2C22%2C23

1 个答案:

答案 0 :(得分:0)

您只需执行URI.decode("...")

即可解码