【发布时间】:2022-08-12 04:09:27
【问题描述】:
从 Rails 6 升级到 Rails 7,然后是 bundle exec rails app:update,突然包装 Postgres timestamp with time zone 列的模型属性返回为 Time 对象而不是 ActiveSupport::TimeWithZone 对象。
Structure.sql 示例
CREATE TABLE public.blogs (
id bigint NOT NULL,
created_at timestamp with time zone,
#...
之前(轨道 6)
Blog.last.created_at.class #=> ActiveSupport::TimeWithZone
之后(轨道 7)
Blog.last.created_at.class #=> Time
如何让 Rails 识别我希望这些列用ActiveSupport::TimeWithZone 包裹?
标签: ruby-on-rails postgresql activerecord