class ActiveStorage::Attached
Abstract base class for the concrete ActiveStorage::Attached::One
and ActiveStorage::Attached::Many
classes that both provide proxy access to the blob association for a record.
Attributes
dependent[R]
name[R]
record[R]
Public Class Methods
new(name, record, dependent:)
click to toggle source
# File activestorage/lib/active_storage/attached.rb, line 13 def initialize(name, record, dependent:) @name, @record, @dependent = name, record, dependent end
Private Instance Methods
create_blob_from(attachable)
click to toggle source
# File activestorage/lib/active_storage/attached.rb, line 18 def create_blob_from(attachable) case attachable when ActiveStorage::Blob attachable when ActionDispatch::Http::UploadedFile, Rack::Test::UploadedFile ActiveStorage::Blob.create_after_upload! \ io: attachable.open, filename: attachable.original_filename, content_type: attachable.content_type when Hash ActiveStorage::Blob.create_after_upload!(attachable) when String ActiveStorage::Blob.find_signed(attachable) else nil end end