show all transactions on index, show user transactions on user show

This commit is contained in:
Felix Van der Jeugt 2015-09-10 16:35:26 +02:00
parent b30e1fb438
commit 2c1c92edb3
3 changed files with 13 additions and 5 deletions

View file

@ -15,7 +15,7 @@ class TransactionsController < ApplicationController
current_user: current_user
)
@grid = TransactionsGrid.new(gridparams) do |scope|
scope.where('debtor_id = :id OR creditor_id = :id', id: current_user).page(params[:page])
scope.page(params[:page])
end
end

View file

@ -4,8 +4,15 @@ class UsersController < ApplicationController
def show
@user = User.find(params[:id])
@transaction = Transaction.new
respond_to do |format|
format.html
gridparams = params[:transactions_grid] || Hash.new
gridparams = gridparams.merge(
order: :created_at,
descending: true,
current_user: current_user
)
@grid = TransactionsGrid.new(gridparams) do |scope|
scope.where('debtor_id = :id OR creditor_id = :id', id: current_user).page(params[:page])
end
end

View file

@ -1,3 +1,4 @@
%tr{:class => "#{options[:cycle] cycle(*options[:cycle])}"}
%tr{class: "#{options[:cycle] && cycle(*options[:cycle])}"}
- grid.html_columns(*options[:columns]).each do |column|
%td{:class => "#{datagrid_column_classes(grid, column)}"}= datagrid_value(grid, column, asset)
%td{:class => "#{datagrid_column_classes(grid, column)}"}
= datagrid_value(grid, column, asset)