我正在尝试做这样的事情:
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.[]=
答案 0 :(得分:13)
您需要首先将会话[:continent]初始化为哈希。试试这个:
session[:continent] ||= {}
session[:continent][:filter] = params[:filter]