-1
用我的軌道主動型串行器(IAM),這是我的片斷主動型串行導軌內的另一個JSON對象JSON不工作
# 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"
},]
但其工作時,只是呈現@用戶
# GET /users
def index
@users = User.all
render json: {data: @users, status: httpstatus[:getSuccess]}
# render json: @users
end
我只是想刪除創建和從json更新。 如何解決這個.. 索裏的英語不好
請遵循https://stackoverflow.com/questions/15397537/rails-model-to-哈希排除的屬性 –