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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c59df522a773c83afb22a2378a12e14dce6cd8b3
4
- data.tar.gz: d74bbf77539f97cc86e993ff8ae0cecdd21f8bc2
3
+ metadata.gz: 7300ac3903e5328e36011a9531566872072943ec
4
+ data.tar.gz: 4f69f49030c1875a48e3d7517258fd074210ec76
5
5
  SHA512:
6
- metadata.gz: 3b1b96bc1e316bb42c4760444a358e38ae77ea07adcb9448b2defb12695505e9b6afa205f28ec8f6a7e292924fc39c10e6cff255ea8717d464b88acfdac32354
7
- data.tar.gz: e6a53bca57082c639dccca3b06aed49a952ae59482918b583de4db343fd13b06ca97d18f537c8a89244ae82ea373d4e9e7e729decc9d83b2963d0b196f5790ea
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
 
@@ -1,5 +1,5 @@
1
1
  module CustomFields #:nodoc
2
2
 
3
- VERSION = '2.4.0.rc5'
3
+ VERSION = '2.4.0.rc6'
4
4
 
5
5
  end
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.rc5
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-09-14 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid