Module: Alchemy::StorageAdapter::Dragonfly::AttachmentClassMethods

Defined in:
app/models/alchemy/storage_adapter/dragonfly.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/alchemy/storage_adapter/dragonfly.rb', line 30

def self.included(base)
  base.class_eval do
    dragonfly_accessor :file, app: :alchemy_attachments do
      after_assign { |file|
        write_attribute(:file_mime_type, file.mime_type)
      }
    end

    before_save if: :file_name do
      self.file_name = sanitized_filename(file_name)
    end
  end
end