简体   繁体   English

Rails TimeZone投入生产

[英]Rails TimeZone in Production

My Server is USA West Coast but all the time that is recorded in the MySQL server should be done in UTC so that i can implement TimeZone for Users at the later date. 我的服务器是美国西海岸,但MySQL服务器中记录的所有时间都应使用UTC进行,以便以后可以为用户实现TimeZone。 Right now Configuring to Indian Timing. 现在配置为印度时间。

Is there any configuration i need to do to get this working. 我需要做任何配置才能使其正常工作。 i have added the following: 我添加了以下内容:

//application.rb
config.time_zone = 'UTC'
config.active_record.default_timezone :utc

Is there any other settings i need to do to tell rails that please save content in the UTC? 我还有其他设置要告诉Rails请在UTC中保存内容吗?

In rails application the time recorded in MySQL is automatically taken in UTC. 在Rails应用程序中,MySQL中记录的时间会自动以UTC记录。 What happens is when you give config.time_zone = 'UTC' in application.rb , the rails converts that time from UTC (stored in MySQL) to the timezone specified in application.rb . 当您在application.rb提供config.time_zone = 'UTC'时,会发生这种情况,rails将该时间从UTC(存储在MySQL中)转换为application.rb指定的时区。 So I think there is nothing required to do that. 因此,我认为不需要这样做。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM