tab/app/controllers/transactions_controller.rb

23 lines
640 B
Ruby
Raw Normal View History

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