Ruby on Rails problems & solutions - Jan 24, 2011

January 25, 2011

Date Formats for Rails 3 It’s surprisingly difficult to find up-to-date, comprehensive info about date formats and time zones for Rails. It’s been a moving target, updated in every release.  This thread pops up a lot:

It’s mostly out of date, but it’s worth a read, just for the variety of interesting solutions.  This article is more recent, and provides comprehensive examples:

Also, there’s some good information here:

But, I have to agree, you need a damn good reason to store anything other than UTC in your database.  If you have UTC, then you always have a basic starting point.

ActiveRecord “update” is annoying

Why isn’t there an update! ?  The only way to tell if there is a problem, is to examine the returned object for validity.  

What to do about 404’s in your Ajax app

Of course, you should know about rescue_from already.  If you don’t, then get to it.  It’s interesting and useful.

But, it’s only useful, if you can use it for all your server-side needs, including your Ajax calls:

} else { $('#cookie-notice').show(); } $('#cookie-notice-accept').click(function() { createCookie('cookie-notice-dismissed','true',365); // Change from 1 month to 1 year. $('#cookie-notice').hide(); });