Skip to content

Commit 4ea8460

Browse files
committed
Update README [ci skip]
1 parent fc02268 commit 4ea8460

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ database.
684684

685685
## ProTips™
686686

687-
### Create a master parent class
687+
### Create a master parent class (Easy)
688688

689689
In the same spirit of Rails `ApplicationController` and `ApplicationRecord`, you can create an `ApplicationDatatable` class (in `app/datatables/application_datatable.rb`)
690690
that will be inherited from other classes :
@@ -700,34 +700,7 @@ end
700700

701701
This way it will be easier to DRY you datatables.
702702

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-
def change
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)"
720-
end
721-
722-
dir.down do
723-
remove_index TABLE.to_sym, name: "#{TABLE}_#{attr}_gin"
724-
end
725-
end
726-
end
727-
end
728-
```
729-
730-
### Speedup JSON rendering
703+
### Speedup JSON rendering (Easy)
731704

732705
Install [yajl-ruby](https://github.com/brianmario/yajl-ruby), basically :
733706

@@ -743,9 +716,9 @@ $ bundle install
743716

744717
That's all :) ([Automatically prefer Yajl or JSON backend over Yaml, if available](https://github.com/rails/rails/commit/63bb955a99eb46e257655c93dd64e86ebbf05651))
745718

746-
### Use HTTP `POST` method
719+
### Use HTTP `POST` method (Medium)
747720

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).
749722

750723
You can easily define a route concern in `config/routes.rb` and reuse it when you need it :
751724

@@ -808,6 +781,33 @@ $ ->
808781
# ...others options, see [here](#5-wire-up-the-javascript)
809782
```
810783

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+
def change
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)"
801+
end
802+
803+
dir.down do
804+
remove_index TABLE.to_sym, name: "#{TABLE}_#{attr}_gin"
805+
end
806+
end
807+
end
808+
end
809+
```
810+
811811
## Tutorial
812812

813813
You'll find a sample project [here](https://github.com/ajahongir/ajax-datatables-rails-v-0-4-0-how-to). Its real world example.

0 commit comments

Comments
 (0)