Rails Cookie Gotchas | June 19th, 2007
Rails breaks the hash implementation that cookies appear, on the surface, to support.
For whatever reason, symbol access of values doesn’t work but string access does. Also, for whatever reason, the nil? method will not work but the empty? method does. Hopefully this saves somebody some frustration!
request.cookies['note'].value unless request.cookies['note'].empty?
Cookies, yum.
July 22nd, 2007 at 4:30 pm
Yes!! This did help me very much!! I was stuck on this part of my application, and it was taking me a while to figure out why.
I also didn’t know about the .value method for the cookie.
Thanks so much!!!
Take care,
Sean