I need to initialize a session var as array.
Where i do that?
when i try to do this:
session[:complains_id] << params[:id]
i get this message
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.<<
I know that i have to initialize the var but i dont know where.
Thanks!
Just do:
Which is saying:
if
session[:complains_id]returnsnil, set it to [].
Append
params[:id]tosession[:complains_id]Demo: