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
+31-31Lines changed: 31 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -684,7 +684,7 @@ database.
684
684
685
685
## ProTips™
686
686
687
-
### Create a master parent class
687
+
### Create a master parent class (Easy)
688
688
689
689
In the same spirit of Rails `ApplicationController` and `ApplicationRecord`, you can create an `ApplicationDatatable` class (in `app/datatables/application_datatable.rb`)
690
690
that will be inherited from other classes :
@@ -700,34 +700,7 @@ end
700
700
701
701
This way it will be easier to DRY you datatables.
702
702
703
-
### Create indices for Postgresql
704
-
705
-
In order to speed up the `ILIKE` queries that are executed when using the default configuration, you might want to consider adding some indices.
706
-
For postgresql, you are advised to use the [gin/gist index type](http://www.postgresql.org/docs/current/interactive/pgtrgm.html).
707
-
This makes it necessary to enable the postgrsql extension `pg_trgm`. Double check that you have this extension installed before trying to enable it.
708
-
A migration for enabling the extension and creating the indices could look like this:
709
-
710
-
```ruby
711
-
defchange
712
-
enable_extension :pg_trgm
713
-
TEXT_SEARCH_ATTRIBUTES= ['your', 'attributes']
714
-
TABLE='your_table'
715
-
716
-
TEXT_SEARCH_ATTRIBUTES.each do |attr|
717
-
reversible do |dir|
718
-
dir.up do
719
-
execute "CREATE INDEX #{TABLE}_#{attr}_gin ON #{TABLE} USING gin(#{attr} gin_trgm_ops)"
That's all :) ([Automatically prefer Yajl or JSON backend over Yaml, if available](https://github.com/rails/rails/commit/63bb955a99eb46e257655c93dd64e86ebbf05651))
745
718
746
-
### Use HTTP `POST` method
719
+
### Use HTTP `POST` method (Medium)
747
720
748
-
Use HTTP `POST` method to avoid `414 Request-URI Too Large` error. See : [#278](https://github.com/jbox-web/ajax-datatables-rails/issues/278).
721
+
Use HTTP `POST` method to avoid `414 Request-URI Too Large` error. See : [#278](https://github.com/jbox-web/ajax-datatables-rails/issues/278) and [#308](https://github.com/jbox-web/ajax-datatables-rails/issues/308#issuecomment-424897335).
749
722
750
723
You can easily define a route concern in `config/routes.rb` and reuse it when you need it :
751
724
@@ -808,6 +781,33 @@ $ ->
808
781
# ...others options, see [here](#5-wire-up-the-javascript)
809
782
```
810
783
784
+
### Create indices for Postgresql (Expert)
785
+
786
+
In order to speed up the `ILIKE` queries that are executed when using the default configuration, you might want to consider adding some indices.
787
+
For postgresql, you are advised to use the [gin/gist index type](http://www.postgresql.org/docs/current/interactive/pgtrgm.html).
788
+
This makes it necessary to enable the postgrsql extension `pg_trgm`. Double check that you have this extension installed before trying to enable it.
789
+
A migration for enabling the extension and creating the indices could look like this:
790
+
791
+
```ruby
792
+
defchange
793
+
enable_extension :pg_trgm
794
+
TEXT_SEARCH_ATTRIBUTES= ['your', 'attributes']
795
+
TABLE='your_table'
796
+
797
+
TEXT_SEARCH_ATTRIBUTES.each do |attr|
798
+
reversible do |dir|
799
+
dir.up do
800
+
execute "CREATE INDEX #{TABLE}_#{attr}_gin ON #{TABLE} USING gin(#{attr} gin_trgm_ops)"
0 commit comments