我正在尝试改变
render json: @users
用active_model_serializers序列化的输出,适配器:json。
我想删除主根密钥,并为每个用户哈希添加密钥“ user”。
正确的方法是什么?
代替
users:
[
{
name: "James Potter",
email: "maren@ipsum.info",
apiKey: "4040ca1534fd1040fs049b472f6sd7991327d",
admin: false,
password: null,
licences: []
}
{
name: "Harry Potter",
email: "maren@tipsum.info",
apiKey: "4040ca1534sdf1040f0d49b472a67991s37dd",
admin: false,
password: null,
licences: []
}
]
}
我正试图得到这样的东西。
{ [
user: {
name: "James Potter",
email: "maren@ipsum.info",
apiKey: "4040ca1534fd1040fs049b472f6sd7991327d",
admin: false,
password: null,
licences: []
}
user: {
name: "Harry Potter",
email: "maren@tipsum.info",
apiKey: "4040ca1534sdf1040f0d49b472a67991s37dd",
admin: false,
password: null,
licences: []
}
] }