In show method for a controller i have @object setup with query
@object = WorkOrder.find(params[:id])
Now, the show.json.jbuilder template has code as:
json.extract! @object, :id, :note, :status, :created_at
json.store_name @object.store.display_name
and the o/p is,
{
"id": 31,
"note": "work_order for store A",
"status": "complete",
"created_at": "2015-11-26T11:16:53.000Z",
"store_name": "store name"
}
Now, how to insert 'store_name' custom key in between 'status' and 'created_at' ?