2015-09-08 13:25:54 +00:00
|
|
|
class TransactionsController < ApplicationController
|
2015-09-09 09:31:34 +00:00
|
|
|
skip_before_filter :verify_authenticity_token, :only => :create
|
2015-09-08 13:25:54 +00:00
|
|
|
|
|
|
|
def index
|
2015-09-08 18:45:32 +00:00
|
|
|
@transactions = Transaction.all
|
2015-09-08 13:25:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@transaction = Transaction.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-09-09 09:31:34 +00:00
|
|
|
@transaction = current_user.outgoing_transactions.build(
|
2015-09-09 10:50:39 +00:00
|
|
|
transaction_params.merge(origin: I18n.t('origin.created_by_user')))
|
2015-09-08 19:07:00 +00:00
|
|
|
|
|
|
|
if @transaction.save
|
|
|
|
redirect_to current_user
|
|
|
|
else
|
|
|
|
render 'new'
|
|
|
|
end
|
2015-09-08 13:25:54 +00:00
|
|
|
end
|
|
|
|
|
2015-09-08 19:07:00 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def transaction_params
|
|
|
|
params.require(:transaction).permit(:creditor_id, :amount, :message)
|
|
|
|
end
|
2015-09-08 13:25:54 +00:00
|
|
|
end
|