Rails 5 warning warning and adding code to initializers?

In which initialization file should I add the desired line of code? I receive the following failure warning.

DEPRECATION WARNING: Time columns will be displayed in Rails 5.1. This still causes String be Time.zone , as if they were in Time.zone , and Time to convert to Time.zone .

To maintain the previous behavior, you must add the following to your initializer:

 config.active_record.time_zone_aware_types = [:datetime] 

To disable this warning, add the following:

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

I am new to rails, I just want to follow best practices. Thanks!

+5
source share
2 answers

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

 config.active_record.time_zone_aware_types = [:datetime, :time] 
+6
source

create the file /config/initializers/time_zone_aware_types.rb then add the following line to the file Rails.application.config.active_record.time_zone_aware_types = [:datetime, :time]

+1
source

Source: https://habr.com/ru/post/1258945/


All Articles