Class: ActiveStorage::Attachment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/active_storage/attachment.rb

Overview

Schema: id, record_gid, blob_id, created_at

Instance Method Summary collapse

Instance Method Details

#purgeObject



22
23
24
25
# File 'lib/active_storage/attachment.rb', line 22

def purge
  blob.purge
  destroy
end

#purge_laterObject



27
28
29
# File 'lib/active_storage/attachment.rb', line 27

def purge_later
  ActiveStorage::PurgeJob.perform_later(self)
end

#recordObject



13
14
15
# File 'lib/active_storage/attachment.rb', line 13

def record
  @record ||= GlobalID::Locator.locate(record_gid)
end

#record=(record) ⇒ Object



17
18
19
20
# File 'lib/active_storage/attachment.rb', line 17

def record=(record)
  @record = record
  self.record_gid = record&.to_gid
end