Skip to content

Commit fc1c987

Browse files
committed
Update README [ci skip]
1 parent 30095db commit fc1c987

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ AjaxDatatablesRails.configure do |config|
9595
# available options for db_adapter are: :pg, :mysql, :mysql2, :sqlite, :sqlite3
9696
# config.db_adapter = :pg
9797

98+
# Or you can use your rails environment adapter if you want a generic dev and production
99+
# config.db_adapter = Rails.configuration.database_configuration[Rails.env]['adapter'].to_sym
100+
98101
# available options for orm are: :active_record, :mongoid
99102
# config.orm = :active_record
100103
end
@@ -204,7 +207,7 @@ end
204207

205208
* `:like`, `:start_with`, `:end_with` for string or full text search
206209
* `:eq`, `:not_eq`, `:lt`, `:gt`, `:lteq`, `:gteq`, `:in` for numeric
207-
* `:date_range` for date range (only for Rails > 4.2.x)
210+
* `:date_range` for date range (only for Rails > 4.2.x, see [here](#daterange-search))
208211
* `:null_value` for nil field
209212
* `Proc` for whatever (see [here](https://github.com/ajahongir/ajax-datatables-rails-v-0-4-0-how-to/blob/master/app/datatables/city_datatable.rb) for real example)
210213

@@ -601,6 +604,21 @@ def get_raw_records
601604
end
602605
```
603606

607+
### Default scope
608+
609+
See [DefaultScope is evil](https://rails-bestpractices.com/posts/2013/06/15/default_scope-is-evil/) and [#223](https://github.com/jbox-web/ajax-datatables-rails/issues/223) and [#233](https://github.com/jbox-web/ajax-datatables-rails/issues/233).
610+
611+
### DateRange search
612+
613+
This feature works with [yadcf](https://github.com/vedmack/yadcf).
614+
615+
To enable the date range search, for example `created_at` :
616+
617+
* add a 'created_at' `<th>` in your html
618+
* declare your column in `view_columns` : `created_at: { source: 'Post.created_at', cond: :date_range, delimiter: '-yadcf_delim-' }`
619+
* add it in `data` : `created_at: record.decorate.created_at`
620+
* setup yadcf to make `created_at` search field a range
621+
604622
### Generator Syntax
605623

606624
Also, a class that inherits from `AjaxDatatablesRails::Base` is not tied to an

0 commit comments

Comments
 (0)