filter_form 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -5
- data/lib/filter_form/money_converter.rb +1 -1
- data/lib/filter_form/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f800cb6aaea8a59d82d5c4e103e445e2adbadab
|
4
|
+
data.tar.gz: 07e42f1373ce8d42bf101372d4bdaec9dbe210f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
`
|
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
|
-
```
|
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
|
data/lib/filter_form/version.rb
CHANGED