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' }); });