From 0e9b60706143309946c3cb455e9aaaae9c7830ef Mon Sep 17 00:00:00 2001 From: redfast00 Date: Thu, 11 Apr 2019 17:34:23 +0200 Subject: [PATCH] Make API more friendly --- app/controllers/transactions_controller.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 6361ad9..b17b4b4 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -4,7 +4,18 @@ class TransactionsController < ApplicationController def index @transactions = @user.transactions respond_to do |format| - format.json { render json: @transactions } + format.json { + render json: @transactions.map {|t| { + :id => t.id, + :debtor => t.debtor.name, + :creditor => t.creditor.name, + :time => t.updated_at, + :amount => t.amount, + :message => t.message, + :issuer => t.issuer.name + } + } + } end end