Module: RailsAdminSettings::Uploads
- Included in:
- Setting
- Defined in:
- lib/rails_admin_settings/uploads.rb,
lib/rails_admin_settings/storage/carrier_wave_uploader.rb
Defined Under Namespace
Classes: CarrierWaveUploader
Class Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/rails_admin_settings/uploads.rb', line 13
def self.included(base)
if base.respond_to?(:mount_uploader)
base.mount_uploader(:file, RailsAdminSettings::Uploads::CarrierWaveUploader)
Settings.file_uploads_supported = true
Settings.file_uploads_engine = :carrierwave
elsif RailsAdminSettings.mongoid? && ::Mongoid.const_defined?('Paperclip')
base.send(:include, ::Mongoid::Paperclip)
base.field(:file, type: String)
base.has_mongoid_attached_file(:file, self.paperclip_options)
if base.respond_to?(:do_not_validate_attachment_file_type)
base.do_not_validate_attachment_file_type :file
end
Settings.file_uploads_supported = true
Settings.file_uploads_engine = :paperclip
elsif RailsAdminSettings.active_record? && defined?(Paperclip)
base.has_attached_file(:file, self.paperclip_options)
if base.respond_to?(:do_not_validate_attachment_file_type)
base.do_not_validate_attachment_file_type :file
end
Settings.file_uploads_supported = true
Settings.file_uploads_engine = :paperclip
else
end
end
|
.paperclip_options ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/rails_admin_settings/uploads.rb', line 5
def self.paperclip_options
if defined?(Rails)
{}
else
{path: "#{File.dirname(__FILE__)}/../../uploads/:filename", url: '/uploads/:filename'}
end
end
|