From 20bb2804821c000774b974a86e92206288648032 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 8 Sep 2015 17:46:07 +0200 Subject: [PATCH] Make transaction datatable actually work --- app/controllers/transactions_controller.rb | 1 + app/datatables/transaction_datatable.rb | 8 ++------ app/views/transactions/index.html.haml | 8 ++++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 29d4051..8d11091 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -1,6 +1,7 @@ class TransactionsController < ApplicationController def index + p params respond_to do |format| format.html format.json { render json: TransactionDatatable.new(view_context) } diff --git a/app/datatables/transaction_datatable.rb b/app/datatables/transaction_datatable.rb index 4db8ecb..628f3fd 100644 --- a/app/datatables/transaction_datatable.rb +++ b/app/datatables/transaction_datatable.rb @@ -1,12 +1,10 @@ class TransactionDatatable < AjaxDatatablesRails::Base def sortable_columns - # Declare strings in this format: ModelName.column_name - @sortable_columns ||= [] + @sortable_columns ||= ['Transaction.id'] end def searchable_columns - # Declare strings in this format: ModelName.column_name @searchable_columns ||= [] end @@ -14,9 +12,7 @@ class TransactionDatatable < AjaxDatatablesRails::Base def data records.map do |record| - [ - record.id, record.debtor.name, record.creditor.name, record.amount - ] + [ record.id, record.debtor.name, record.creditor.name, record.amount ] end end diff --git a/app/views/transactions/index.html.haml b/app/views/transactions/index.html.haml index b078bba..06c0462 100644 --- a/app/views/transactions/index.html.haml +++ b/app/views/transactions/index.html.haml @@ -10,9 +10,9 @@ :javascript $(document).ready(function() { $('#transactions').DataTable({ - processing: true, - serverSide: true, - ajaxSource: $('#transactions').data('source'), - pagingType: 'full_numbers' + 'processing': true, + 'serverSide': true, + 'ajax': $('#transactions').data('source'), + 'pagingType': 'full_numbers' }); });