ruby-on-rails - Created_at nil 即使在成功创建后
问题描述
我正在构建一个跟踪应用程序,当我尝试在我的 Rails 控制台上创建新的跟踪时遇到了一个奇怪的问题。
首先,它创建并且可以保存“created_at”值,但是当我放置“Tracking.last”之后,它根本没有“created_at”。
irb(main):005:0> Tracking.create(latitude: 1241214, longitude: 12421412, comment: "testing")
(0.2ms) BEGIN
Tracking Create (0.4ms) INSERT INTO "trackings" ("comment", "created_at", "updated_at", "longitude", "latitude") VALUES ($1,
$2, $3, $4, $5) RETURNING "id" [["comment", "testing"],
["created_at", "2019-06-13 18:14:57.019001"], ["updated_at",
"2019-06-13 18:14:57.019001"], ["longitude", 12421412.0],
["latitude", 1241214.0]]
(0.5ms) COMMIT
=> #<Tracking id: 3, comment: "testing", created_at: "2019-06-13
21:14:57", updated_at: "2019-06-13 21:14:57", longitude:
12421412.0, latitude: 1241214.0>
irb(main):006:0> Tracking.last
Tracking Load (0.5ms) SELECT "trackings".* FROM "trackings"
ORDER BY "trackings"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> #<Tracking id: 3, comment: "testing", created_at: nil,
updated_at: nil, longitude: 12421412.0, latitude: 1241214.0>
我在这里想念什么?
解决方案
推荐阅读
- django - RedirectView 给 NoReverseMatch
- c# - 是否有 SSRS 表达式用于计算不包括周末、周六和周日的两天之间的差异?
- scala - 为什么编译器无法识别属性?
- awk - 如何将带有awk的行合并到具有相同键的一行
- sql - 使用 CTE 删除 Greenplum 中的真实重复
- git - 从公共分支中删除重复提交
- magento - Magento 2 Rest API 从会话令牌(React Native App)中获取客户 ID
- flutter - 从导航堆栈弹出后打开屏幕时调用哪个函数?
- algorithm - log(nf(n)) 是 log(n) 的大 theta
- typescript - 在 VS Code 中折叠 tsx 文件中的类型定义