filter_form 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6189d3b110196894801cee283b727c4dc3018086
4
- data.tar.gz: af46f72476125da17a24b32f887d6cba28ff58d2
3
+ metadata.gz: 6f800cb6aaea8a59d82d5c4e103e445e2adbadab
4
+ data.tar.gz: 07e42f1373ce8d42bf101372d4bdaec9dbe210f2
5
5
  SHA512:
6
- metadata.gz: 17c3223cc02252a317a0a6ad186ef4c28a938141abbad1ffa94292fd790df2d4b0aa2395dfb73d9ae4abad771ae3d4953ace647269d6750eb2435ffde8b07838
7
- data.tar.gz: 56fbb4db9539de5d13bc1882a32295e8f1363f95e88fea3c87745d230b130d085fe653bf95ecaac8a2824fc43cbc3aa34834c0267cc40863bf9918c689d4ecf1
6
+ metadata.gz: 53c0115af667c010f1087661d680e186ef43b01cb247abd8cb6ac1236c39a474be9be75b7be4b79aa1bf5c4f6d906a7a93c16e6d041aae0a76859ef948a214db
7
+ data.tar.gz: 65a55c70e9fd3c028f470c8d4fa8db138fe18b51f8f27a56bdca147eb42ffb7316a81a0d70e1e3de08d56b3af523eb9cfa3deb78490ff1ebc6a83004ff3c94c5
data/README.md CHANGED
@@ -48,17 +48,18 @@ In your view file:
48
48
 
49
49
  Mapping | Database Column Type | Default predicate | Generated HTML Element |
50
50
  --------------- |:------------------------------------------------|:----------------------|:--------------------------|
51
+ `boolean` | `boolean` | `true` | `input[type=checkbox]` |
51
52
  `string` | `string` | `cont` | `input[type=text]` |
52
53
  `text` | `text` | `cont` | `input[type=text]` |
53
54
  `integer` | `integer` | `eq` | `input[type=number]` |
54
55
  `float` | `float` | `eq` | `input[type=number]` |
55
56
  `decimal` | `decimal` | `eq` | `input[type=number]` |
56
- `money` | `money` [monetized](https://github.com/RubyMoney/money-rails) attribute | `eq` | `input[type=number]` |
57
- `datetime` | `datetime` | `eq` | `input[type=text]` |
58
57
  `date` | `date` | `eq` | `input[type=text]` |
58
+ `datetime` | `datetime` | `eq` | `input[type=text]` |
59
+ `select` | `select` | `eq` | `select` |
59
60
  `belongs_to` | `belongs_to` association | `eq` | `select` |
60
61
  `collection` | `has_many` or `has_and_belongs_to_many` association | `eq` | `select` |
61
- `boolean` | `boolean` | `true` | `input[type=checkbox]` |
62
+ `money` | `money` [monetized](https://github.com/RubyMoney/money-rails) attribute | `eq` | `input[type=number]` |
62
63
 
63
64
  ### Customization
64
65
 
@@ -84,9 +85,9 @@ You can show predicate selector:
84
85
 
85
86
  #### Money
86
87
 
87
- To filter by monetized attribute please add your controller:
88
+ To filter by monetized attribute please add to your controller:
88
89
 
89
- ```erb
90
+ ```ruby
90
91
  class ApplicationController < ActionController::Base
91
92
  include FilterForm::MoneyConverter
92
93
  ...
@@ -15,7 +15,7 @@ module FilterForm
15
15
  money_attribute_name = money_column_name.dup.gsub('_cents', '')
16
16
  money_param_name = params[:q].keys.select { |c| c.start_with?(money_attribute_name) }.first
17
17
 
18
- if money_param_name
18
+ if money_param_name && params[:q][money_param_name].present?
19
19
  params[:q][money_param_name.gsub(money_attribute_name, "#{ money_attribute_name }_cents")] = params[:q].delete(money_param_name).to_f * 100
20
20
  end
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module FilterForm
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filter_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Li