add create controller and dummy view

This commit is contained in:
Felix Van der Jeugt 2015-09-08 17:30:02 +02:00
parent c1563980c4
commit 363c825e55
3 changed files with 24 additions and 1 deletions

View file

@ -9,6 +9,10 @@ class TransactionsController < ApplicationController
end
def create
creditor = User.find params.require(:transaction).require(:creditor)
debtor = current_user
amount = params.require(:transaction).require(:amount)
@transaction = Transaction.create debtor: debtor, creditor: creditor, amount: amount, origin: I18n.t('origin.created_by_user'), message: "Transaction by #{debtor.name} to #{creditor.name}"
end
end

View file

@ -0,0 +1,17 @@
%table
%tbody
%tr
%th Debtor
%td= @transaction.debtor.name
%tr
%th Creditor
%td= @transaction.creditor.name
%tr
%th Amount
%td= @transaction.amount
%tr
%th Origin
%td= @transaction.origin
%tr
%th Message
%td= @transaction.message

View file

@ -20,4 +20,6 @@
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"
origin:
created_by_user: "User"