Attaching file to ActiveStorage without HTTP
October 13, 2020
If you want to attach a file you generated on disk or downloaded from a user-submitted URL, you can do it like this.
@model.image.attach(
io: File.open('/path/to/file'),
filename: 'file.pdf',
# content type is optional
content_type: 'application/pdf'
)