ajax-datatables-rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c6d1a02fa3eea0fe1ec630d8d8d1679ead410eb
4
- data.tar.gz: e8ed8700b2578035252dfcfeda21a02090df0f8d
3
+ metadata.gz: 0e4fd5aaceea2d7736b1557eb21380da1bd58391
4
+ data.tar.gz: 10e47fdae2640f298aa19785e90c3a738e5f7237
5
5
  SHA512:
6
- metadata.gz: 61c70886ea5166a34bbe3dab9b98d62bcf0a3170d69583c07de17d9174ab69c08c079256607b07fa8c513309d2320093edac02a23480695ad615aa36c49acba7
7
- data.tar.gz: 6db28cdf46a920d24c9270dbb136befb5bbbc5663eaccef145f1dafed24d900c53643269a4f764499e83fac217208e63526c27717024afe05110b780c6d25d5f
6
+ metadata.gz: d353c16571573cf843d9a5fd5c29752bbab75d0e37f98ec60c4767f34f7d07934f5138f08df356408e3ed0c6dc1de75a7eeae2c6e6ad914b02e48dceeba98d58
7
+ data.tar.gz: 8c34fe263c1c38b37447e9328a10a65da66f36ada2e847a38cf1665ec0c9f5fc4f74054ed02fa2121a988cbabfca6228e91d5b5191b2f52383643e3791c6870c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.2
4
+ * Fixes `where` clause being built even when search term is an empty string.
5
+ Thanks to [e-fisher](https://github.com/e-fisher) for spotting and fixing this.
6
+
3
7
  ## 0.1.1
4
8
  * Fixes problem on `searchable_columns` where the corresponding model is
5
9
  a composite model name, e.g. `UserData`, `BillingAddress`.
data/README.md CHANGED
@@ -30,7 +30,7 @@ Adding support for `Sequel`, `Mongoid` and `MongoMapper` is a planned feature fo
30
30
  Add these lines to your application's Gemfile:
31
31
 
32
32
  gem 'jquery-datatables-rails'
33
- gem 'rails-datatables'
33
+ gem 'ajax-datatables-rails'
34
34
 
35
35
  And then execute:
36
36
 
@@ -118,6 +118,8 @@ def data
118
118
  end
119
119
  ```
120
120
 
121
+ [See here](#using-view-helpers) if you need to use view helpers in the returned 2d array, like `link_to`, `mail_to`, `resource_path`, etc.
122
+
121
123
  #### Get Raw Records
122
124
  ```ruby
123
125
  def get_raw_records
@@ -205,6 +207,36 @@ jQuery(document).ready(function() {
205
207
 
206
208
  ### Additional Notes
207
209
 
210
+ #### Using view helpers
211
+
212
+ 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.
213
+
214
+ To have these methods available to be used, this is the way to go:
215
+
216
+ ```ruby
217
+ class MyCustomDatatable < AjaxDatatablesRails::Base
218
+ # either define them one-by-one
219
+ def_delegator :@view, :link_to
220
+ def_delegator :@view, :h
221
+ def_delegator :@view, :mail_to
222
+
223
+ # or define them in one pass
224
+ def_delegators :@view, :link_to, :h, :mailto, :edit_resource_path, :other_method
225
+
226
+ # now, you'll have these methods available to be used anywhere
227
+ # example: mapping the 2d jsonified array returned.
228
+ def data
229
+ records.map do |record|
230
+ [
231
+ link_to(record.fname, edit_resource_path(record)),
232
+ mail_to(record.email),
233
+ # other attributes
234
+ ]
235
+ end
236
+ end
237
+ end
238
+ ```
239
+
208
240
  #### Options
209
241
 
210
242
  An `AjaxDatatablesRails::Base` inherited class can accept an options hash at initialization. This provides room for flexibility when required. Example:
@@ -99,7 +99,7 @@ module AjaxDatatablesRails
99
99
  def aggregate_query
100
100
  conditions = searchable_columns.each_with_index.map do |column, index|
101
101
  value = params["sSearch_#{index}".to_sym]
102
- search_condition(column, value) if value
102
+ search_condition(column, value) unless value.blank?
103
103
  end
104
104
  conditions.compact.reduce(:and)
105
105
  end
@@ -1,3 +1,3 @@
1
1
  module AjaxDatatablesRails
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ajax-datatables-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Quenneville
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-13 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties