Last active
December 20, 2015 09:30
-
-
Save andyhite/6108412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do you want something like this... | |
class CitiesDatatable < Datatable | |
datatable class_name: 'City', search_keys: [:name] | |
end | |
# where you would access the Datatable information like this, where self == controller.view_context ... | |
cities_datatable = CitiesDatatable.new(self) | |
cities_datatable.to_json # => { sEcho: 1, iTotalRecords: 20, iTotalDisplayRecords: 10, aaData: [...] } | |
# or something like this ... | |
class City < ActiveRecord::Base | |
include Datatables | |
define_datatable search_keys: [:name] | |
end | |
# where you would access the Datatable information via something like this, where self == controller.view_context ... | |
City.datatable(self) # => { sEcho: 1, iTotalRecords: 20, iTotalDisplayRecords: 10, aaData: [...] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment