Rails: Cookies, Frozen Gems, and TextDrive

Jon Steinhorst once told me a movies are rewritten from script to shoot, and again from shoot to editing. I spent a good chunk of this week re-writing a Ruby on Rails app to go from development to production.

Works fine in development. Not at all in production.

The issue was a combination of frozen gems and cookies.

First off, while TextDrive recommends depending on your vendor directory for any Ruby gems unique to your project, I found success with Geoffrey Grosenbach‘s Freeze Other Gems Rake task that sends them to /lib

Secondly, I wasn’t able to reliably set and retrieve cookies. Turns out I needed to access the cookie with a string, not a symbol.

All the resources I found say this should work in the controller
cookies[:the_timezone]

But it doesn’t, this does:
cookies['the_timezone']

Then in the view (specifically a select menu) I need to use this:
time_zone_options_for_select(cookies['the_timezone'].value,TZInfo::Timezone.us_zones,TZInfo::Timezone)

Leave a Reply

Your email address will not be published. Required fields are marked *