Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用postgres数据库在rails中只节省时间的最佳方法?_Ruby On Rails_Ruby_Postgresql - Fatal编程技术网

Ruby on rails 使用postgres数据库在rails中只节省时间的最佳方法?

Ruby on rails 使用postgres数据库在rails中只节省时间的最佳方法?,ruby-on-rails,ruby,postgresql,Ruby On Rails,Ruby,Postgresql,我有个小小的想法,在rails中存储时间的最好方法是什么 我脑子里可能有三个选择 将其存储为DateTime,但忽略日期部分 以秒/分钟为单位将其存储为整数 将其存储为十进制 你能给我什么建议,为什么?:) 博士后13 Rails 6.0.3 Ruby 2.7.2与兼容。它将使用 您可以手动将时间与时区一起使用,这也将映射到时间,但它将保留时区 add_列(:yourtable,:time_at,'time with timezone') 有关如何在Rails中使用时间的更多信息,请参阅。可以使

我有个小小的想法,在rails中存储时间的最好方法是什么

我脑子里可能有三个选择

  • 将其存储为DateTime,但忽略日期部分
  • 以秒/分钟为单位将其存储为整数
  • 将其存储为十进制
  • 你能给我什么建议,为什么?:)

    博士后13

    Rails 6.0.3

    Ruby 2.7.2与兼容。它将使用

    您可以手动将
    时间与时区一起使用
    ,这也将映射到时间,但它将保留时区

    add_列(:yourtable,:time_at,'time with timezone')

    有关如何在Rails中使用时间的更多信息,请参阅。

    可以使用值。