blob: 8ca4ee9239a81efde8a288b25cbd1f33cb367ce1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
module Terraform
class State < ApplicationRecord
belongs_to :project
validates :project_id, presence: true
after_save :update_file_store, if: :saved_change_to_file?
mount_uploader :file, StateUploader
def update_file_store
# The file.object_store is set during `uploader.store!`
# which happens after object is inserted/updated
self.update_column(:file_store, file.object_store)
end
def file_store
super || StateUploader.default_store
end
end
end
|