add uuid to active storage blob

This commit is contained in:
Pete Matsyburka committed 2024-02-18 10:42:11 +02:00
1 parent 652072d660
commit 5a3174a720
3 files changed
+22 -1

No files matched your search

+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