how to append data to json in ruby/rails?

后端 未结 6 821
南方客
南方客 2020-12-31 00:29

Say i have this short code:

item = Item.find(params[:id])
render :json => item.to_json

but i needed to insert/push extra information to

6条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 00:55

    item = Item.find(params[:id])
    item["message"] = "it works"
    render :json => item.to_json
    

提交回复
热议问题