我是Ruby的新手,所以这个问题对您来说可能看起来很愚蠢,是的。但是还是...我有一个模型组,当我运行它时
class GroupsController < ApplicationController
prepend SimpleCommand
...
def index
@group = Group.all
render json: @group
end
...
# some other stuff
Run Code Online (Sandbox Code Playgroud)
...然后我得到一个如下数组的响应:
[
{
"id": 1020,
"name": "??-16-1",
"has_subgroups": true,
"created_at": "2017-09-29T10:14:08.000Z",
"updated_at": "2017-09-29T10:14:08.000Z"
}
...
]
Run Code Online (Sandbox Code Playgroud)
但是我不想拥有最后两个字段,所以我的答案是如何在响应中摆脱“ created_at”和“ updated_at”字段?
在原始问题中找到了一个很好的解决方案,而我不小心为此做了一个重复。继续阅读