当我运行User.only(:name).all
该查询或该查询的任何变体时,我得到:
[#<User _id: 52003fb8487874985b
000003, created_at: nil, updated_at: nil, role_ids: nil, name: "Tom Amfeagfhbdge Bowersman", usernam
e: nil, fb_id: nil, fb_token: nil, email: nil, encrypted_password: nil, reset_password_token: nil, r
eset_password_sent_at: nil, remember_created_at: nil, sign_in_count: nil, current_sign_in_at: nil, l
ast_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil>,
#<User _id: 5200405a487874fb550
00004, created_at: nil, updated_at: nil, role_ids: nil, name: "Carol Amfdheibbjbf Sadanwitz", userna
me: nil, fb_id: nil, fb_token: nil, email: nil, encrypted_password: nil, reset_password_token: nil,
reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: nil, current_sign_in_at: nil,
last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil>,
#<User _id: 520040d14878746fe5
000005, created_at: nil, updated_at: nil, role_ids: nil, name: "Tom Amfdidheeidd Yangson", username:
nil, fb_id: nil, fb_token: nil, email: nil, encrypted_password: nil, reset_password_token: nil, res
et_password_sent_at: nil, remember_created_at: nil, sign_in_count: nil, current_sign_in_at: nil, las
t_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil>]
除了唯一函数的参数外,我文档中的所有字段都返回 nil 值。
我想得到类似这样的结果:
"data": [
{
"id": "5008484"
},
{
"id": "47402727"
},
{
"id": "500154435"
},
{
"id": "500598450"
},
{
"id": "500655911"
},
{
"id": "500666528"
},
{
"id": "500700148"
},
{
"id": "500973616"
},
{
"id": "501130485"
},
{
"id": "501254060"
}]
而不是“id”,“name”