On 12 April 2011 22:40, Stephen H. Gerstacker <[email protected]> wrote:
> I've been working on the internal app for my company which is well
> over 4 years old.  First commit was using Rails 1.1.6.
>
> I'm now at 2.3.11 and I have a branch of my code that is converted to
> 3.0.6, but I just noticed a problem.  The Rails 3 branch is pushing
> timestamps with time zone manipulation.  I knew that Rails had a new
> way to handle time zones, but up through 2.3.11, I haven't had to
> change anything.
>
> Is there a setting to change?  I saw
> "ActiveRecord::Base.time_zone_aware_attributes = true" in the docs.
>
> The problem I have now is that is I pull a record from before the
> conversion, the created_at timestamp is correct at "Mon, 02 Feb 2009
> 10:59:10 UTC +00:00" because that was the local time here (ignoring
> the UTC part).  Now when I create a new record, I get "Tue, 12 Apr
> 2011 21:20:10 UTC +00:00" which is 5:20 Eastern.

Are you sure exactly what is in the database itself?  A datetime field
does not contain a timezone indication so the stamps you are showing
above are a Rails interpretation of what is there.  First I suggest
you look at the db itself using phpmyadmin or whatever is your
favourite tool to check exactly what is there.

>
>
> My ultimate question is, what should I do?  I'd hate to have to switch
> the app to use config.time_zone = "Eastern..." and then run a script
> to touch every single timestamp and convert it in the database...

If your statement above about what is actually in the db is correct
then since timestamps in the database should always be in UTC it is
the earlier data that is incorrect.  In your situation I would write a
migration to update all the earlier ones (assuming that it actually
matters whether the earlier data has the correct values).

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to