我的默认代码是Lab.all
,当我只是像Lab.all.to_json那样呈现完美的json
{"id":1,"lab_id":1,"test_id":2,"price_cents":20000,"duration":null,"created_at":"2016-02-26T14:40:40.825Z","updated_at":"2016-02-26T14:40:40.825Z"}
我有以下范围:
@lab_tests = LabTest.group(:lab).sum(:price_cents)
并以json:
{"#\u003cLab:0x007f8e0a44afa8\u003e":20000}
如何让它像这样渲染json:
{"id":1,"lab_id":1,"test_id":2,"price_cents":20000,"duration":null,"created_at":"2016-02-26T14:40:40.825Z","updated_at":"2016-02-26T14:40:40.825Z", "price_cents":200000 }
我尝试在我的范围中添加.select
参数,但即使这样也不会改变任何内容。