tab/app/controllers/transactions_controller.rb

30 lines
611 B
Ruby
Raw Normal View History

2015-09-08 13:25:54 +00:00
class TransactionsController < ApplicationController
def index
2015-09-08 15:30:13 +00:00
respond_to do |format|
format.html
format.json { render json: TransactionDatatable.new(view_context) }
end
2015-09-08 13:25:54 +00:00
end
def new
@transaction = Transaction.new
end
def create
2015-09-08 19:07:00 +00: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 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