Skip to content

Commit 11ffb58

Browse files
committed
Updates README and CHANGELOG for release.
1 parent 470e497 commit 11ffb58

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# CHANGELOG
22

3-
## (yet) Unreleased
3+
## 0.2.1
44
* Fix count method to work with select statements under Rails 4.1. Thanks to [Jason Mitchell](https://github.com/mitchej123) for the contribution.
55
* Edits to `README` documentation about the `options` hash. Thanks to [Jonathan E Hogue](https://github.com/hoguej) for pointing out that previous documentation was confusing and didn't address its usage properly.
66
* Edits to `README` documentation on complex model queries inside the `get_raw_records` method. A round of applause to [Zoltan Paulovics](https://github.com/zpaulovics) for contributing this awesome piece of documentation. :smile:
77
* Adds typecast step to `search_condition` method, so now we support having non-text columns inside the `searchable_columns` array.
88
* Adds support for multi-column sorting and multi-term search. Thanks to [Zoltan Paulovics](https://github.com/zpaulovics) for contributing this feature.
9+
* Adds optional config initializer, so we can have a base to typecast non text-based columns and perform searches depending on the use of `:mysql2`, `:sqlite3` or `:pg`. Thanks to [M. Saiqul Haq](https://github.com/saiqulhaq) for contributing this feature.
910

1011
## 0.2.0
1112
* This version works with jQuery dataTables ver. 1.10 and it's new API syntax.

README.md

+40-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Adding support for `Sequel`, `Mongoid` and `MongoMapper` is a planned feature fo
3838

3939
Add these lines to your application's Gemfile:
4040

41-
gem 'jquery-datatables-rails', git: 'git://github.com/rweng/jquery-datatables-rails.git', branch: 'master'
41+
gem 'jquery-datatables-rails'
4242
gem 'ajax-datatables-rails'
4343

4444
And then execute:
@@ -50,7 +50,8 @@ jQuery dataTables to your Rails project. You can always add the plugin assets
5050
manually via the assets pipeline. If you decide to use the `jquery-datatables-rails` gem, please refer to its installation instructions [here](https://github.com/rweng/jquery-datatables-rails).
5151

5252
## Usage
53-
*The following examples assume that we are setting up ajax-datatables-rails for an index of users from a `User` model*
53+
*The following examples assume that we are setting up ajax-datatables-rails for an index of users from a `User` model, and that we are using postgresql as
54+
our db, because you __should be using it__, if not, please refer to the [Searching on non text-based columns](#searching-on-non-text-based-columns) entry in the Additional Notes section.*
5455

5556
### Generate
5657
Run the following command:
@@ -92,6 +93,7 @@ the gems bundled in your project. For example, if your models are using `Kaminar
9293
* For `searchable_columns`, assign an array of the database columns that you want searchable by datatables. For example `[users.f_name, users.l_name]`
9394

9495
This gives us:
96+
9597
```ruby
9698
include AjaxDatatablesRails::Extensions::Kaminari
9799

@@ -102,9 +104,10 @@ end
102104
def searchable_columns
103105
@searchable_columns ||= ['users.f_name', 'users.l_name']
104106
end
105-
106107
```
107108

109+
[See here](#searching-on-non-text-based-columns) for notes regarding database config (if using something different from `postgre`).
110+
108111
### Map data
109112
```ruby
110113
def data
@@ -297,6 +300,40 @@ jQuery(document).ready(function() {
297300

298301
### Additional Notes
299302

303+
#### Searching on non text-based columns
304+
305+
It always comes the time when you need to add a non-string/non-text based column to the `@searchable_columns` array, so you can perform searches against these column types (example: numeric, date, time).
306+
307+
We recently added the ability to (automatically) typecast these column types and have this scenario covered. Please note however, if you are using something different from `postgre` (with the `:pg` gem), like `mysql` or `sqlite`, then you need to add an initializer in your application's `config/initializers` directory.
308+
309+
If you don't perform this step (again, if using something different from `postgre`), your database will complain that it does not understand the default typecast used to enable such searches.
310+
311+
You have two options to create this initializer:
312+
313+
* use the provided (and recommended) generator (and then just edit the file);
314+
* create the file from scratch.
315+
316+
To use the generator, from the terminal execute:
317+
318+
```
319+
$ bundle exec rails generate datatable:config
320+
```
321+
322+
Doing so, will create the `config/initializers/ajax_datatables_rails.rb` file with the following content:
323+
324+
```ruby
325+
AjaxDatatablesRails.configure do |config|
326+
# available options for db_adapter are: :pg, :mysql2, :sqlite3
327+
# config.db_adapter = :pg
328+
end
329+
```
330+
331+
Uncomment the `config.db_adapter` line and set the corresponding value to your
332+
database and gem. This is all you need.
333+
334+
If you want to make the file from scratch, just copy the above code block into a file inside the `config/initializers` directory.
335+
336+
300337
#### Using view helpers
301338

302339
Sometimes you'll need to use view helper methods like `link_to`, `h`, `mailto`, `edit_resource_path` in the returned JSON representation returned by the `data` method.

0 commit comments

Comments
 (0)