Module: RailsAdminSettings::Uploads
- Included in:
- Setting
- Defined in:
- lib/rails_admin_settings/uploads.rb,
lib/rails_admin_settings/storage/carrierwave.rb
Defined Under Namespace
Classes: CarrierWave
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rails_admin_settings/uploads.rb', line 5 def self.included(base) # carrierwave if base.respond_to?(:mount_uploader) # puts "[rails_admin_settings] CarrierWave detected" # base.field(:file, type: String) base.mount_uploader(:file, RailsAdminSettings::Uploads::CarrierWave) Settings.file_uploads_supported = true Settings.file_uploads_engine = :carrierwave # paperclip elsif Mongoid.const_defined?('Paperclip') base.send(:include, Mongoid::Paperclip) # puts "[rails_admin_settings] PaperClip detected" base.field(:file, type: String) if defined?(Rails) base.has_mongoid_attached_file(:file) else base.has_mongoid_attached_file(:file, path: "#{File.dirname(__FILE__)}/../../uploads/:filename", url: '/uploads/:filename') end base.send(:attr_accessor, :delete_file) base.before_validation { self.file.clear if self.delete_file == '1' } Settings.file_uploads_supported = true Settings.file_uploads_engine = :paperclip else # puts "[rails_admin_settings] Uploads disabled" end end |