DataTables warning (table id = 'job_runs'): Requested unknown parameter '8' from the data source for

DataTables warning (table id = 'job_runs'): Requested unknown parameter '8' from the data source for

sidmanutdsidmanutd Posts: 3Questions: 2Answers: 0
edited May 2014 in General

"DataTables warning (table id = 'job_runs'): Requested unknown parameter '8' from the data source for"

I am getting the above error. Do not know what is wrong ?

JS:

jQuery ->
  $('#job_runs').dataTable
    bProcessing: true
    bServerSide: true
    sAjaxSource: $('#job_runs').data('source')

Datatable file :

class JobrunsDatatable
  delegate :params, to: :@view

  def initialize(view)
    @view = view
  end

  def as_json(options = {})
    {
      sEcho: params[:sEcho].to_i,
      iTotalRecords: JobRun.count,
      iTotalDisplayRecords: job_runs.count,
      aaData: data
    }
  end

private

  def data
    job_runs.map do |run|
      [
        run.source,
        run.client_id,
        run.environment_id,
        run.job_id,
        run.start_time,
        run.end_time,
        run.duration,
        run.status
      ]
    end
  end

  def job_runs
    @job_runs ||= fetch_job_runs
  end

  def fetch_job_runs
    job_runs = JobRun.order("#{sort_column} #{sort_direction}")
    job_runs = job_runs.page(page).per_page(per_page)
    if params[:sSearch].present?
      job_runs = job_runs.where("name like :search", search: "%#{params[:sSearch]}%")
    end
    job_runs
  end

  def page
    params[:iDisplayStart].to_i/per_page + 1
  end

  def per_page
    params[:iDisplayLength].to_i > 0 ? params[:iDisplayLength].to_i : 10
  end

  def sort_column
    columns = %w[source client_id environment_id job_id start_time end_time duration status]
    columns[params[:iSortCol_0].to_i]
  end

  def sort_direction
    params[:sSortDir_0] == "desc" ? "desc" : "asc"
  end
end

Read the previous posts regarding the same error but had no luck. I have been following the Railscast to get Datatables working

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.