From 5963766d840ddcdb577a1bd10eb1491a4ef9132f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 9 Jul 2017 18:48:26 +0200 Subject: Explore regular polymorphic associations rather than record_gid --- app/models/active_storage/attachment.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'app/models') diff --git a/app/models/active_storage/attachment.rb b/app/models/active_storage/attachment.rb index 20c619aa5a..1dd202ca45 100644 --- a/app/models/active_storage/attachment.rb +++ b/app/models/active_storage/attachment.rb @@ -6,19 +6,11 @@ require "active_support/core_ext/module/delegation" class ActiveStorage::Attachment < ActiveRecord::Base self.table_name = "active_storage_attachments" + belongs_to :record, polymorphic: true belongs_to :blob, class_name: "ActiveStorage::Blob" delegate_missing_to :blob - def record - @record ||= GlobalID::Locator.locate(record_gid) - end - - def record=(record) - @record = record - self.record_gid = record&.to_gid - end - def purge blob.purge destroy -- cgit v1.2.3 From eb9b019fee51cff69dfcbf19e6c326c426acc297 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 23 Jul 2017 16:28:45 -0500 Subject: Return to same level of abstraction --- app/models/active_storage/variant.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/active_storage/variant.rb b/app/models/active_storage/variant.rb index 435033f980..002d2bde5b 100644 --- a/app/models/active_storage/variant.rb +++ b/app/models/active_storage/variant.rb @@ -11,7 +11,7 @@ class ActiveStorage::Variant end def processed - process unless service.exist?(key) + process unless processed? self end @@ -25,6 +25,10 @@ class ActiveStorage::Variant private + def processed? + service.exist?(key) + end + def process service.upload key, transform(service.download(blob.key)) end -- cgit v1.2.3 From e16d0c9ceacd771c99048385dc886c6026c7bc45 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 23 Jul 2017 16:57:26 -0500 Subject: No more GlobalID --- app/models/active_storage/attachment.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'app/models') diff --git a/app/models/active_storage/attachment.rb b/app/models/active_storage/attachment.rb index 1dd202ca45..d491c7224e 100644 --- a/app/models/active_storage/attachment.rb +++ b/app/models/active_storage/attachment.rb @@ -1,5 +1,4 @@ require "active_storage/blob" -require "global_id" require "active_support/core_ext/module/delegation" # Schema: id, record_gid, blob_id, created_at -- cgit v1.2.3