ruby-on-rails – 如何在与rails的会话中设置多维数组
发布时间:2020-12-16 22:14:17 所属栏目:百科 来源:网络整理
导读:我想做这样的事情: session[:continent][:filter] = params[:filter] 但它不起作用,我得到了这个错误: You have a nil object when you didn't expect it!You might have expected an instance of Array.The error occurred while evaluating nil.[]= 解决
我想做这样的事情:
session[:continent][:filter] = params[:filter] 但它不起作用,我得到了这个错误: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[]= 解决方法
您需要首先将会话[:continent]初始化为哈希.试试这个:
session[:continent] ||= {} session[:continent][:filter] = params[:filter] (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |