This project is archived and is in readonly mode.
[Rails 2.3.1] Time zone information is not loaded from fixtures
-
Geoff Buesing
What did you expect, and what did you get instead?
Try using just Time.now.utc, see if that fixes things.
-
Ashrafuzzaman
If I use Time.now.utc or Time.now in fixtures where my database field is datetime it gives error,
ActiveRecord::StatementInvalid: Mysql::Error: Incorrect datetime value: 'Sun Apr 12 11:40:05 UTC 2009' for column 'deadline' at row 1: INSERT INTO
job_assignments(job_id,updated_at,id,deadline,transporter_fee,transporter_id,created_at,state) VALUES (245383586, '2009-04-12 09:40:07', 809788707, 'Sun Apr 12 11:40:05 UTC 2009', 75, 468814034, '2009-04-12 09:40:07', 'assigned')Let me descripbe the problem in detail. I want to use something like Time.now.utc or DateTime.now.utc in fixtures to get the time with localization support. Using Time.now.utc gives error in fixtures. And using DateTime.now.utc does not give expected output(with timezone information).
-
Geoff Buesing
Aha ok -- looks like you're not calling #to_s(:db) -- 'Sun Apr 12 11:40:05 UTC 2009' is the plain Time#to_s output.
You need to explicitly call #to_s(:db) on time objects that you insert into fixtures via erb, like so:
deadline: <%= Time.now.utc.to_s(:db) %>
-
Geoff Buesing
- State changed from new to invalid