This will return all the data that DataTables expects including all the relevant rows from the database.
# File app/datatables/universities_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(University, conditions) end
This fetches the correct page of data in the correct order.
# File app/datatables/universities_datatable.rb, line 17 def data_hash(university) { id: university.id, name: link_to(university.name, admin_path(university_id: university.subdomain), target: :_blank), subdomain: university.subdomain, active: admin_university_activation_link(university) } end
Provide the sequence in which columns to be sorted.
# File app/datatables/universities_datatable.rb, line 27 def sort_columns %w(name subdomain active) end