This will return all the data that DataTables expects including all the relevant rows from the database.
# File app/datatables/companies_datatable.rb, line 7 def as_json(options = {}) conditions = if params[:sSearch].present? ["LOWER(name) LIKE :q", q: "%#{params[:sSearch].downcase}%"] else {} end as_datatable(Company, conditions) end
This fetches the correct page of data in the correct order.
# File app/datatables/companies_datatable.rb, line 17 def data_hash(company) { id: company.id, name: link_to(company.name, admin_path(company_id: company.subdomain), target: :_blank), subdomain: company.subdomain, active: admin_company_activation_link(company) } end
Provide the sequence in which columns to be sorted.
# File app/datatables/companies_datatable.rb, line 27 def sort_columns %w(name subdomain active) end