diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 2b25fde..a547d98 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -13,7 +13,7 @@ class TransactionsController < ApplicationController current_user: current_user ) @grid = TransactionsGrid.new(gridparams) do |scope| - scope.page(params[:page]) + scope.where('debtor_id = :id OR creditor_id = :id', id: current_user).page(params[:page]) end end diff --git a/app/grids/transactions_grid.rb b/app/grids/transactions_grid.rb index dd5617e..f7e4ba8 100644 --- a/app/grids/transactions_grid.rb +++ b/app/grids/transactions_grid.rb @@ -6,8 +6,6 @@ class TransactionsGrid scope do Transaction - #@current_user.transactions - # TODO how to get current user here? end self.default_column_options = { order: false } @@ -18,7 +16,7 @@ class TransactionsGrid column(:amount) filter(:amount, :integer, range: true) - column(:peer) { |model, scope, grid| model.peer_of(grid.current_user).try(:name) } + column(:peer) { |model, grid| model.peer_of(grid.current_user).try(:name) } filter(:peer, :string, header: 'Peer') do |value, scope, grid| scope.joins(debtor: 'id', creditor: 'id') .where("(debtor_id = :user AND creditor.name LIKE :name) OR (creditor_id = :user AND debtor.name LIKE :name)", user: grid.current_user.id, name: "%#{value}%")