instance method
attach!
Ruby on Rails edge
Since edgeSignature
attach!(attachable)
Calls attach, and raises an exception if the record was meant to be saved but at least one of the validations failed.
person.avatar.attach!(params[:avatar]) # ActionDispatch::Http::UploadedFile object
person.avatar.attach!(params[:signed_blob_id]) # Signed reference to blob from direct upload
person.avatar.attach!(io: File.open("/path/to/face.jpg"), filename: "face.jpg", content_type: "image/jpeg")
person.avatar.attach!(avatar_blob) # ActiveStorage::Blob object
Parameters
-
attachablereq
Source
# File activestorage/lib/active_storage/attached/one.rb, line 78
def attach!(attachable)
attach(attachable) || raise(ActiveRecord::RecordNotSaved.new("Failed to save the record", record))
end
Defined in activestorage/lib/active_storage/attached/one.rb line 78
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveStorage::Attached::One