This commit is contained in:
benji 2015-09-09 11:54:59 +02:00
commit a2ae293df0
3 changed files with 15 additions and 2 deletions

View file

@ -7,6 +7,10 @@ class ApplicationController < ActionController::Base
redirect_to root_url, alert: exception.message redirect_to root_url, alert: exception.message
end end
def current_client
@current_client ||= identify_client
end
def current_ability def current_ability
if current_user if current_user
@current_ability ||= Ability.new(current_user) @current_ability ||= Ability.new(current_user)
@ -14,4 +18,12 @@ class ApplicationController < ActionController::Base
@current_ability ||= ClientAbility.new(current_account) @current_ability ||= ClientAbility.new(current_account)
end end
end end
private
def identify_client
key = request.headers["X-API-KEY"]
Client.find_by key: key if key
end
end end

View file

@ -8,7 +8,8 @@ class TransactionsController < ApplicationController
end end
def create def create
@transaction = current_user.outgoing_transactions.build transaction_params.merge(origin: I18n.t('origin.created_by_user')) @transaction = current_user.outgoing_transactions.build(
transaction_params.merge(origin: I18n.t('origin.created_by_user'))
if @transaction.save if @transaction.save
redirect_to current_user redirect_to current_user

View file

@ -2,7 +2,7 @@ class TransactionDatatable < AjaxDatatablesRails::Base
include TransactionsHelper include TransactionsHelper
def sortable_columns def sortable_columns
@sortable_columns ||= ['Transaction.amount'] @sortable_columns ||= ['Transaction.created_at']
end end
def searchable_columns def searchable_columns