问题描述
如何修改Rails应用程序,使其始终在模型的created_at
字段中包含毫秒信息?
How do I modify my Rails app to always include the milliseconds information with the created_at
field of my models?
给出了如何针对单个模型进行操作的答案,但我想在全球范围内进行操作.
This question has the answer for how to do it for an individual model, but I want to do it globally.
例如,当我检索所有Item
模型(通过用GET击/items
)时,将获得以下JSON:
For example, when I retrieve all my Item
models (by hitting /items
with a GET), I get the following JSON:
[{"created_at":"2011-08-07T23:42:15Z","updated_at":"2011-08-07T23:42:15Z","id":180,"user_id":6,"content":"test"}]
但是请注意,created_at
字段没有有关创建该毫秒的信息.如何在我的所有模型中包含它?
But note that the created_at
field doesn't have any information about the millisecond that it was created. How do I include that for all my models?
推荐答案
我能够使用本指南.
任何人都知道如何在所有型号上做到这一点吗?
Anyone know how to do it for all models?
这篇关于Rails:对于每个模型,始终包含带有created_at的毫秒数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!