How to store array on a cookie rails 4?

前端 未结 3 1046
再見小時候
再見小時候 2021-01-20 01:03

I am trying to store an array on rails an getting error on the decoding. I use cookies[:test] = Array.new And when I am trying to decode @test = ActiveSupp

3条回答
  •  执念已碎
    2021-01-20 02:01

    Use session, not cookies. You don't have to decode it, rails handles that for you. Create the session the same way you already are:

    session[:test] = Array.new
    

    and when you need it, access it like normal

    session[:test]
    # => []
    

提交回复
热议问题