add uuid to active storage blob

This commit is contained in:
Pete Matsyburka
2024-02-18 10:24:43 +02:00
parent 652072d660
commit 5a3174a720
3 changed files with 22 additions and 1 deletions
+10
View File
@@ -19,6 +19,16 @@ ActiveSupport.on_load(:active_storage_attachment) do
end
ActiveSupport.on_load(:active_storage_blob) do
attribute :uuid, :string, default: -> { SecureRandom.uuid }
def uuid
super || begin
new_uuid = SecureRandom.uuid
update_columns(uuid: new_uuid)
new_uuid
end
end
def delete
service.delete(key)
end