This will return all the data that DataTables expects including all the relevant rows from the database.
# File app/datatables/courses_datatable.rb, line 6 def as_json(options = {}) conditions = if params[:sSearch].present? ["LOWER(name) LIKE :q", q: "%#{params[:sSearch].downcase}%"] else {} end as_datatable(@options[:subject].courses, conditions) end
This fetches the correct page of data in the correct order.
# File app/datatables/courses_datatable.rb, line 16 def data_hash(course) { id: course.id, name: course.name, description: course.description, action: admin_action_link(course) } end
Provide the sequence in which columns to be sorted.
# File app/datatables/courses_datatable.rb, line 26 def sort_columns ['name', 'description'] end