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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c97a9164b3261a278b1f3301269d033c3745924
4
- data.tar.gz: ab3202cae5b8b60bfcb29d417d405c9eeadefb9d
3
+ metadata.gz: 41b1a552f6a1354a2b634cf8a23abac17ce397b4
4
+ data.tar.gz: 1cd897947e6db09f0e32543a57d89121348d7eb0
5
5
  SHA512:
6
- metadata.gz: ffab683cf013c7a8370f77d3f09804217e5710c89f2d560f2a1e2fb56df8cab72887667e37a5ba75fa8ae2c8979ac9b1456ab5d5ec839e06cbe9849ca10f98d3
7
- data.tar.gz: 24302382c64724b139af6d0fd6d1d9eac2e411f43ca255df746cefff608b24ec3f8abc5f96289eba5f7d264c886d3c3cec2b414f6142af5753e96b779e7699f3
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
 
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module CustomFields #:nodoc
3
3
 
4
- VERSION = '2.3.3'
4
+ VERSION = '2.3.4'
5
5
 
6
6
  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.3.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-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