My rails 4.1.7.1 app is working perfectly. At least, the way I would like it to. However, after upgrading to 4.2 (using the official upgrade guides), I've got some issues.
First. Using DateTime.parse throws an error: 'undefined method `getlocal' . The code is:
# Add the schedule
schedule_in_db = Schedule
.where(
:event_id => event_in_db.id,
:ext_id => schedule['id']
)
.first_or_create!(
:start_time => DateTime.parse(schedule['start_time']), # example value: 2014-12-18T14:00:00.000+00:00"
:end_time => DateTime.parse(schedule['end_time']),
:type_id => type_in_db.id
)
To fix this, I used Time.parse or Time.zone.parse instead. That fixes the error. However, a new problem appears. My start_time and end_time variables get padded one hour ahead. So that 08:15 becomes 09:15.
Here's my app.rb config:
config.time_zone = 'Stockholm' #uncommented and set to proper zone
config.active_record.default_timezone = :local
config.active_record.time_zone_aware_attributes = false
No matter what combos I try, my events are still one hour ahead.
Funny thing is, that after creating the schedule, this returns zero schedules:
Schedule.where start_time: schedule['start_time']
This returns the correct row, however:
Schedule.where start_time: Time.parse(schedule['start_time'])
I guess my question is this: Why is rails 4.2 acting so differently than 4.1.7.1 with the same codebase in regards to dates and times? And what is the remedy?