Sha256: c28b6a67c000f5d30d7e848d510761e1298c167d117246326f1bfdd3d21118d6

Contents?: true

Size: 614 Bytes

Versions: 3

Compression:

Stored size: 614 Bytes

Contents

module EffectiveLogging
  module ActiveStorageLogger

    def track_downloads
      user = current_user if respond_to?(:current_user)

      key = decode_verified_key()
      return unless key.present?

      blob = ActiveStorage::Blob.where(key: key[:key]).first
      return unless blob.present?

      blob.attachments.each do |attachment|
        associated = attachment.record
        filename = blob.filename.to_s
        message = [associated.to_s, filename.to_s].uniq.join(' ')

        EffectiveLogger.download(message, associated: associated, filename: filename, user: user)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
effective_logging-3.1.1 lib/effective_logging/active_storage_logger.rb
effective_logging-3.1.0 lib/effective_logging/active_storage_logger.rb
effective_logging-3.0.13 lib/effective_logging/active_storage_logger.rb