You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71-2Lines changed: 71 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -225,7 +225,7 @@ def data
225
225
last_name: record.last_name,
226
226
email: record.email,
227
227
bio: record.bio,
228
-
DT_RowId: record.id, # This will set the id attribute on the corresponding <tr> in the datatable
228
+
DT_RowId: record.id, # This will automagically set the id attribute on the corresponding <tr> in the datatable
229
229
}
230
230
end
231
231
end
@@ -398,6 +398,8 @@ class MyCustomDatatable < AjaxDatatablesRails::Base
398
398
end
399
399
```
400
400
401
+
### Using view decorators
402
+
401
403
If you want to keep things tidy in the data mapping method, you could use
402
404
[Draper](https://github.com/drapergem/draper) to define column mappings like below.
403
405
@@ -640,7 +642,9 @@ In the end, it's up to the developer which model(s), scope(s), relationship(s)
640
642
(or else) to employ inside the datatable class to retrieve records from the
641
643
database.
642
644
643
-
### Creating indices for Postgresql
645
+
## Pro Tips
646
+
647
+
### Create indices for Postgresql
644
648
645
649
In order to speed up the `ILIKE` queries that are executed when using the default configuration, you might want to consider adding some indices.
646
650
For postgresql, you are advised to use the [gin/gist index type](http://www.postgresql.org/docs/current/interactive/pgtrgm.html).
@@ -683,6 +687,71 @@ $ bundle install
683
687
684
688
That's all :) ([Automatically prefer Yajl or JSON backend over Yaml, if available](https://github.com/rails/rails/commit/63bb955a99eb46e257655c93dd64e86ebbf05651))
685
689
690
+
### Use HTTP `POST` method
691
+
692
+
Use HTTP `POST` method to avoid `414 Request-URI Too Large` error. See : [#278](https://github.com/jbox-web/ajax-datatables-rails/issues/278).
693
+
694
+
You can easily define a route concern in `config/routes.rb` and reuse it when you need it :
0 commit comments