【发布时间】:2017-05-30 07:25:03
【问题描述】:
我在我的 Rails 中使用活动模型序列化程序,这是我的 sn-p
# GET /users
def index
@users = User.all
render json: {data: @users, status: httpstatus[:getSuccess]}
# render json: {data: @users, status: httpstatus[:getSuccess]}
end
但它在邮递员中是这样显示的
"data": [
{
"id": 38,
"name": "tyasa",
"age": 21,
"created_at": "2017-05-30T06:23:03.504Z",
"updated_at": "2017-05-30T06:23:03.504Z"
},
{
"id": 39,
"name": "wahyu",
"age": 21,
"created_at": "2017-05-30T06:23:37.359Z",
"updated_at": "2017-05-30T06:23:37.359Z"
},]
但它只在渲染 @users 时起作用
# GET /users
def index
@users = User.all
render json: {data: @users, status: httpstatus[:getSuccess]}
# render json: @users
end
我只想从 json 中删除创建于并更新于。 这个怎么解决。。 英语不好
【问题讨论】:
标签: ruby-on-rails json ruby active-model-serializers