Sha256: 934568dcdc3b3a3321cb6056f55394856a52e4294cdd6e8e654191574c18158a

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 Bytes

Contents

module RailsAdminSettings
  module Uploads
    autoload :CarrierWave, "rails_admin_settings/storage/carrierwave"

    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 base.respond_to?(:has_mongoid_attached_file)
        # puts "[rails_admin_settings] PaperClip detected"
        base.field(:file, type: String)
        base.has_mongoid_attached_file(:file)
        Settings.file_uploads_supported = true
        Settings.file_uploads_engine = :paperclip
      else
        # puts "[rails_admin_settings] Uploads disabled"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_admin_settings-0.3.7 lib/rails_admin_settings/uploads.rb
rails_admin_settings-0.3.6 lib/rails_admin_settings/uploads.rb
rails_admin_settings-0.3.4 lib/rails_admin_settings/uploads.rb