Create user when he/she doesn't exist yet and name provided through api
This commit is contained in:
parent
1fba3b98be
commit
cd939f2bf1
1 changed files with 2 additions and 2 deletions
|
@ -25,8 +25,8 @@ class TransactionsController < ApplicationController
|
||||||
.permit(:debtor, :creditor, :message, :euros, :cents)
|
.permit(:debtor, :creditor, :message, :euros, :cents)
|
||||||
|
|
||||||
{
|
{
|
||||||
debtor: User.find_by(name: t[:debtor]) || User.zeus,
|
debtor: t[:debtor] ? User.find_or_create_by(name: t[:debtor]) : User.zeus,
|
||||||
creditor: User.find_by(name: t[:creditor]) || User.zeus,
|
creditor: t[:creator] ? User.find_or_create_by(name: t[:creditor]) : User.zeus,
|
||||||
issuer: current_client || current_user,
|
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]
|
message: t[:message]
|
||||||
|
|
Loading…
Reference in a new issue