instance method attach!

Ruby on Rails edge

Since edge

Signature

attach!(*attachables)

Calls attach, and raises an exception if the record was meant to be saved but at least one of the validations failed.

document.images.attach!(params[:images]) # Array of ActionDispatch::Http::UploadedFile objects
document.images.attach!(params[:signed_blob_id]) # Signed reference to blob from direct upload
document.images.attach!(io: File.open("/path/to/racecar.jpg"), filename: "racecar.jpg", content_type: "image/jpeg")
document.images.attach!([ first_blob, second_blob ])

Parameters

attachables rest
Source
# File activestorage/lib/active_storage/attached/many.rb, line 65
    def attach!(*attachables)
      attach(*attachables) || raise(ActiveRecord::RecordNotSaved.new("Failed to save the record", record))
    end

Defined in activestorage/lib/active_storage/attached/many.rb line 65 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveStorage::Attached::Many

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close