in Hacking

Incompatible Rails Local Configuration

Today I experienced a problem when upgrading to rails 4.2 from rails 3.

When updating an Activerecord object with a DateTime value, I've got the following error:

NoMethodError: undefined method `getlocal' for Mon, 01 Jan -4712 00:00:00 +0000:DateTime

I had the following configuration in my Application object:

  config.active_record.default_timezone = :local  # store all values in the local time-zone 
  config.active_record.time_zone_aware_attributes = false # ignore the time zone

I don't want time-zone information for this project.
But getting an error isn't nice so I solved it by enabling the time_zone_aware_attributes.

  config.active_record.default_timezone = :local  # store all values in the local time-zone 
  config.active_record.time_zone_aware_attributes = true # ignore the time zone
  • Related Content by Tag