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
Minor styling edits to README. Updates to CHANGELOG
* Polishes syntax highlighting on contributed README content from
[Zoltan Paulovics](https://github.com/zpaulovics).
* Updates CHANGELOG to document what is currently unreleased.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,10 @@
1
1
# CHANGELOG
2
2
3
+
## (yet) Unreleased
4
+
* Fix count method to work with select statements under Rails 4.1. Thanks to [Jason Mitchell](https://github.com/mitchej123) for the contribution.
5
+
* 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.
6
+
* 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:
7
+
3
8
## 0.2.0
4
9
* This version works with jQuery dataTables ver. 1.10 and it's new API syntax.
5
10
* Added `legacy` branch to repo. If your project is working with jQuery
@@ -12,7 +17,7 @@
12
17
13
18
## 0.1.1
14
19
* Fixes problem on `searchable_columns` where the corresponding model is
15
-
a composite model name, e.g. `UserData`, `BillingAddress`.
20
+
a composite model name, e.g. `UserData`, `BillingAddress`.
16
21
Thanks to [iruca3](https://github.com/iruca3) for the fix.
17
22
18
23
## 0.1.0
@@ -25,8 +30,8 @@ Thanks to [iruca3](https://github.com/iruca3) for the fix.
25
30
* Removes dependency to pass in a model name to the generator. This way,
26
31
the developer has more flexibility to implement whatever datatable feature is required.
27
32
* Datatable constructor accepts an optional `options` hash to provide
28
-
more flexibility.
33
+
more flexibility.
29
34
See [README](https://github.com/antillas21/ajax-datatables-rails/blob/master/README.mds#options) for examples.
30
35
* Sets generator inside the `Rails` namespace. To generate an
31
36
`AjaxDatatablesRails` child class, just execute the
32
-
generator like this: `$ rails generate datatable NAME`.
37
+
generator like this: `$ rails generate datatable NAME`.
Copy file name to clipboardExpand all lines: README.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -154,7 +154,7 @@ this method, will be chained (for now) to `ActiveRecord` methods for sorting, fi
154
154
#### Associated and nested models
155
155
The previous example has only one single model. But what about if you have some associated nested models and in a report you want to show fields from these tables.
156
156
157
-
Take an example that has an Event, Course, Coursetype, Allocation, Teacher, Contact, Competency and Competency_type models. We want to have a datatables report which has the following column:
157
+
Take an example that has an `Event, Course, Coursetype, Allocation, Teacher, Contact, Competency and CompetencyType` models. We want to have a datatables report which has the following column:
158
158
```ruby
159
159
'coursetypes.name',
160
160
'courses.name',
@@ -195,22 +195,34 @@ We want to sort and search on all columns of the list. The related definition wo
1. In the list we show full_name, but in sortable_columns and searchable_columns we use last_name from the Contact model. The reason is we can use only database columns as sort or search fields and the full_name is not a database field.
209
+
1. In the list we show `full_name`, but in `sortable_columns` and `searchable_columns` we use `last_name` from the `Contact` model. The reason is we can use only database columns as sort or search fields and the full_name is not a database field.
205
210
206
-
2. In the get_raw_records method we have quite a complex query having one to many and may to many associations using the joins ActiveRecord method. The joins will generate INNER JOIN relations in the SQL query. In this case we do not include all event in the report if we have events which is not associated with any model record from the relation.
211
+
2. In the `get_raw_records` method we have quite a complex query having one to many and may to many associations using the joins ActiveRecord method. The joins will generate INNER JOIN relations in the SQL query. In this case we do not include all event in the report if we have events which is not associated with any model record from the relation.
207
212
208
-
3. To have all event records in the list we should use the .includes method, which generate LEFT OUTER JOIN relation of the SQL query. __IMPORTANT:__ Make sure to append .references(:related_model) with any associated model. That forces the eager loading of all the associated models by one SQL query, and the search condition for any column works fine. Otherwise the :recordsFiltered => filter_records(get_raw_records).count(:all) will generate 2 SQL queries (one for the Event model, and then another for the associated tables). The :recordsFiltered => filter_records(get_raw_records).count(:all) will use only the first one to return from the ActiveRecord::Relation object in get_raw_records and you will get an error message of __Unknown column 'yourtable.yourfield' in 'where clause'__ in case the search field value is not empty.
213
+
3. To have all event records in the list we should use the `.includes` method, which generate LEFT OUTER JOIN relation of the SQL query. __IMPORTANT:__ Make sure to append `.references(:related_model)` with any associated model. That forces the eager loading of all the associated models by one SQL query, and the search condition for any column works fine. Otherwise the `:recordsFiltered => filter_records(get_raw_records).count(:all)` will generate 2 SQL queries (one for the Event model, and then another for the associated tables). The `:recordsFiltered => filter_records(get_raw_records).count(:all)` will use only the first one to return from the ActiveRecord::Relation object in `get_raw_records` and you will get an error message of __Unknown column 'yourtable.yourfield' in 'where clause'__ in case the search field value is not empty.
0 commit comments