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



12
13
14
# File 'app/models/db_file.rb', line 12

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



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

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

  class_eval { mount_uploader data, PolymorphicUploader, mount_on: serialization_column }
end