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/active_storage') 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