Class: AjaxDatatablesRails
- Inherits:
-
Object
- Object
- AjaxDatatablesRails
- Defined in:
- lib/ajax-datatables-rails.rb
Overview
require ‘rails’
Defined Under Namespace
Classes: MethodError
Constant Summary collapse
- VERSION =
'0.0.1'
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
-
#searchable_columns ⇒ Object
readonly
Returns the value of attribute searchable_columns.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(view) ⇒ AjaxDatatablesRails
constructor
A new instance of AjaxDatatablesRails.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(view) ⇒ AjaxDatatablesRails
Returns a new instance of AjaxDatatablesRails.
11 12 13 |
# File 'lib/ajax-datatables-rails.rb', line 11 def initialize(view) @view = view end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
15 16 17 |
# File 'lib/ajax-datatables-rails.rb', line 15 def method_missing(meth, *args, &block) @view.send(meth, *args, &block) end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
9 10 11 |
# File 'lib/ajax-datatables-rails.rb', line 9 def columns @columns end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
9 10 11 |
# File 'lib/ajax-datatables-rails.rb', line 9 def model_name @model_name end |
#searchable_columns ⇒ Object (readonly)
Returns the value of attribute searchable_columns.
9 10 11 |
# File 'lib/ajax-datatables-rails.rb', line 9 def searchable_columns @searchable_columns end |
Instance Method Details
#as_json(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ajax-datatables-rails.rb', line 19 def as_json( = {}) { sEcho: params[:sEcho].to_i, iTotalRecords: @model_name.count, iTotalDisplayRecords: filtered_record_count, aaData: data } end |