custom_fields 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/custom_fields/types/file.rb +19 -1
- data/lib/custom_fields/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41b1a552f6a1354a2b634cf8a23abac17ce397b4
|
4
|
+
data.tar.gz: 1cd897947e6db09f0e32543a57d89121348d7eb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38424e89463d3223cccf7c6663d8a06583b45d7cbfde534fb58dadb4e18db267f9ae22ccf8609d17af567903d04c5079950429350b55c8cc00230f0ce946de28
|
7
|
+
data.tar.gz: 36cf663eb585b4cf26d0d3ac6dc5301d0bfe4074a56bddd94e9e157587e3dc8dcd92ef949ff2c6d43a82fe437d86757614ee01ad192aa234ceb20354d781ad47
|
@@ -27,7 +27,11 @@ module CustomFields
|
|
27
27
|
end
|
28
28
|
|
29
29
|
if rule['required']
|
30
|
-
klass.validates_presence_of name
|
30
|
+
# FIXME: previously, we called "klass.validates_presence_of name"
|
31
|
+
# but it didn't work well with localized fields.
|
32
|
+
klass.validate do |object|
|
33
|
+
UploaderPresenceValidator.new(object, name).validate
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -64,6 +68,20 @@ module CustomFields
|
|
64
68
|
|
65
69
|
end
|
66
70
|
|
71
|
+
class UploaderPresenceValidator
|
72
|
+
|
73
|
+
def initialize(document, name)
|
74
|
+
@document, @name = document, name
|
75
|
+
end
|
76
|
+
|
77
|
+
def validate
|
78
|
+
if @document.send(@name).blank?
|
79
|
+
@document.errors.add(@name, :blank)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
67
85
|
class FileUploader < ::CarrierWave::Uploader::Base
|
68
86
|
end
|
69
87
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|