tab/app/controllers/transactions_controller.rb

26 lines
519 B
Ruby
Raw Normal View History

2015-09-08 15:25:54 +02:00
class TransactionsController < ApplicationController
def index
2015-09-08 20:45:32 +02:00
@transactions = Transaction.all
2015-09-08 15:25:54 +02:00
end
def new
@transaction = Transaction.new
end
def create
2015-09-08 21:07:00 +02:00
@transaction = current_user.outgoing_transactions.build transaction_params.merge(origin: I18n.t('origin.created_by_user'))
if @transaction.save
redirect_to current_user
else
render 'new'
end
2015-09-08 15:25:54 +02:00
end
2015-09-08 21:07:00 +02:00
private
def transaction_params
params.require(:transaction).permit(:creditor_id, :amount, :message)
end
2015-09-08 15:25:54 +02:00
end