custom_fields 2.4.0.rc5 → 2.4.0.rc6
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: 7300ac3903e5328e36011a9531566872072943ec
|
4
|
+
data.tar.gz: 4f69f49030c1875a48e3d7517258fd074210ec76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 494214dab5c2cd0d3b57109ec8c7b54fd60d31be8a3f7b41825fd5424030a35020e946f2436da88c69354721bac2226009f34b38db9b1329efb3ef14a51e138f
|
7
|
+
data.tar.gz: 5d3f2c4651ad04fca0f125c4c6674351a1209cef765a0007a337c885dd9e0b2091df8570c584175d3f4b91898bb0fed3bb31e69581a55b69c363e9fcb684ab4a
|
@@ -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.4.0.
|
4
|
+
version: 2.4.0.rc6
|
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
|