From 6c04a90f680a5499692cfff34146cd178ce26870 Mon Sep 17 00:00:00 2001 From: benji Date: Mon, 14 Sep 2015 10:32:58 +0200 Subject: [PATCH] Return new transaction on create --- app/controllers/transactions_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 3452f6e..6db16fd 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -3,6 +3,7 @@ class TransactionsController < ApplicationController before_action :authenticate_user!, except: :create before_action :authenticate_user_or_client!, only: :create + respond_to :js, only: :create def create @@ -11,7 +12,7 @@ class TransactionsController < ApplicationController authorize!(:create, @transaction) if @transaction.save - head :created + render json: @transaction, status: :created else render json: @transaction.errors.full_messages, status: :unprocessable_entity @@ -28,7 +29,7 @@ class TransactionsController < ApplicationController debtor: t[:debtor] ? User.find_or_create_by(name: t[:debtor]) : User.zeus, creditor: t[:creditor] ? User.find_or_create_by(name: t[:creditor]) : User.zeus, issuer: current_client || current_user, - amount: (t[:euros].to_f*100 + t[:cents].to_f).to_i, + amount: (t[:euros].to_f * 100 + t[:cents].to_f).to_i, message: t[:message] } end