When writing to a cookie, I usually convert the array to a string.
def save_options(options) cookies[:options] = (options.class == Array) ? options.join(',') : '' end
Then I convert back to array when reading the cookie.
def options_array cookies[:options] ? cookies[:options].split(",") : [] end
I am not sure if this is the โright wayโ, but it works well for me.
source share