aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/active_storage
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2017-07-09 18:48:26 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2017-07-23 21:17:17 +0200
commit5963766d840ddcdb577a1bd10eb1491a4ef9132f (patch)
treee6cba96cac8865435486ba08a1a5fc0f04d6e9f7 /app/models/active_storage
parent4efbeaeaab72be070e203f39726b37703c1db1fa (diff)
downloadrails-5963766d840ddcdb577a1bd10eb1491a4ef9132f.tar.gz
rails-5963766d840ddcdb577a1bd10eb1491a4ef9132f.tar.bz2
rails-5963766d840ddcdb577a1bd10eb1491a4ef9132f.zip
Explore regular polymorphic associations rather than record_gid
Diffstat (limited to 'app/models/active_storage')
-rw-r--r--app/models/active_storage/attachment.rb10
1 files changed, 1 insertions, 9 deletions
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