rails_admin_settings 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,8 +21,9 @@ module RailsAdminSettings
21
21
 
22
22
  include RailsAdminSettings::RequireHelpers
23
23
  include RailsAdminSettings::Processing
24
- include RailsAdminSettings::Validation
25
24
  include RailsAdminSettings::Uploads
25
+ include RailsAdminSettings::Validation
26
+
26
27
 
27
28
  def disabled?
28
29
  !enabled
@@ -36,9 +36,11 @@ module RailsAdminSettings
36
36
  !bindings[:object].file_type?
37
37
  end
38
38
  end
39
- field :file do
40
- visible do
41
- bindings[:object].file_type?
39
+ if Settings.file_uploads_supported
40
+ field :file, Settings.file_uploads_engine do
41
+ visible do
42
+ bindings[:object].file_type?
43
+ end
42
44
  end
43
45
  end
44
46
  end
@@ -7,16 +7,6 @@ class Settings
7
7
  @@loaded = false
8
8
  @@settings = {}
9
9
 
10
- def file_uploads_supported
11
- load!
12
- @@file_uploads_supported
13
- end
14
-
15
- def file_uploads_engine
16
- load!
17
- @@file_uploads_engine
18
- end
19
-
20
10
  def load!
21
11
  if @@loaded
22
12
  false
@@ -16,6 +16,9 @@ module RailsAdminSettings
16
16
  # puts "[rails_admin_settings] PaperClip detected"
17
17
  base.field(:file, type: String)
18
18
  base.has_mongoid_attached_file(:file)
19
+ base.send(:attr_accessor, :delete_file)
20
+ base.before_validation { self.file.clear if self.delete_file == '1' }
21
+
19
22
  Settings.file_uploads_supported = true
20
23
  Settings.file_uploads_engine = :paperclip
21
24
  else
@@ -1,3 +1,3 @@
1
1
  module RailsAdminSettings
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -290,7 +290,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
290
290
  version: '0'
291
291
  segments:
292
292
  - 0
293
- hash: -511900026411857171
293
+ hash: -2779903626978757826
294
294
  required_rubygems_version: !ruby/object:Gem::Requirement
295
295
  none: false
296
296
  requirements:
@@ -299,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
299
  version: '0'
300
300
  segments:
301
301
  - 0
302
- hash: -511900026411857171
302
+ hash: -2779903626978757826
303
303
  requirements: []
304
304
  rubyforge_project:
305
305
  rubygems_version: 1.8.25