Module: DbFile::Uploader

Included in:
Document, LocationReport, PlateVolume, QcFile, StudyReport
Defined in:
app/models/db_file.rb

Overview

This module will set up all required associations and allow mounting “polymorphic uploaders”

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


10
11
12
# File 'app/models/db_file.rb', line 10

def self.extended(base)
  base.has_many :db_files, as: :owner, dependent: :destroy
end

Instance Method Details

#has_uploaded(data, options) ⇒ Object

Mount an uploader on the specified 'data' column

- you can use the serialisation option for saving the filename in another column - see Carrierwave

16
17
18
19
20
21
22
# File 'app/models/db_file.rb', line 16

def has_uploaded(data, options)
  serialization_column = options.fetch(:serialization_column, data.to_s)

  class_eval do
    mount_uploader data, PolymorphicUploader, mount_on: serialization_column
  end
end