Welcome to mirror list, hosted at ThFree Co, Russian Federation.

file_store_mounter.rb « concerns « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bfcf8a1e7b9f96dde567b7ff79dc047eb42405ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module FileStoreMounter
  extend ActiveSupport::Concern

  class_methods do
    def mount_file_store_uploader(uploader)
      mount_uploader(:file, uploader)

      # This hook is a no-op when the file is uploaded after_commit
      after_save :update_file_store, if: :saved_change_to_file?
    end
  end

  def update_file_store
    # The file.object_store is set during `uploader.store!` and `uploader.migrate!`
    update_column(:file_store, file.object_store)
  end
end