From dbc533a1cb101b6c7f642ac944402b5781a0ef28 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Wed, 9 Sep 2015 11:56:13 +0200 Subject: [PATCH] mess around with api params --- app/controllers/transactions_controller.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 5257ce8..dbe77c7 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -22,7 +22,13 @@ class TransactionsController < ApplicationController private - def transaction_params - params.require(:transaction).permit(:creditor_id, :amount, :message) + def set_params + t = params.require(:transaction) + .permit(:debtor, :creditor, :amount, :message) + + t.update { + debtor: User.find_by(name: t[:debtor]) || User.zeus, + creditor: User.find_by(name: t[:creditor]) || User.zeus + } end end