Class: Datatable
- Inherits:
-
Object
- Object
- Datatable
- Defined in:
- lib/generators/templates/datatable.rb
Constant Summary collapse
- DEFAULT =
{ per_page: 10, truncate_length: 50, na: 'N/A' }
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(view, klass, columns_for_search: [], columns_for_sort: [], options: {}) ⇒ Datatable
constructor
A new instance of Datatable.
Constructor Details
#initialize(view, klass, columns_for_search: [], columns_for_sort: [], options: {}) ⇒ Datatable
Returns a new instance of Datatable.
16 17 18 19 20 21 |
# File 'lib/generators/templates/datatable.rb', line 16 def initialize(view, klass, columns_for_search: [], columns_for_sort: [], options: {}) @view = view @klass = klass @columns_for_search = columns_for_search @columns_for_sort = columns_for_sort end |
Instance Method Details
#as_json(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/generators/templates/datatable.rb', line 23 def as_json( = {}) { sEcho: params[:sEcho].to_i, iTotalRecords: @klass.count, iTotalDisplayRecords: items.total_count, data: data } end |