Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 5 deprecation warning and adding code to initializers?

To which initializer file should I add the desired line of code? I'm getting the following deprecation warning.

DEPRECATION WARNING: Time columns will become time zone aware in Rails 5.1. This still causes Strings to be parsed as if they were in Time.zone, and Times to be converted to Time.zone.

To keep the old behavior, you must add the following to your initializer:

config.active_record.time_zone_aware_types = [:datetime]

To silence this deprecation warning, add the following:

config.active_record.time_zone_aware_types = [:datetime, :time]

I'm a rails newbie, I just want to follow best practice. Thanks!

like image 420
Dan Avatar asked Oct 28 '16 15:10

Dan


1 Answers

add to config/application.rb inside class Application < Rails::Application this line:

config.active_record.time_zone_aware_types = [:datetime, :time]
like image 96
vipantonio Avatar answered Oct 05 '22 21:10

vipantonio