HTTP を介さずに ActiveStorage にファイルを添付する
2020年10月13日
ディスク上に生成したファイルや、ユーザーが送信した URL からダウンロードしたファイルを添付したい場合は、次のようにできます。
@model.image.attach(
io: File.open('/path/to/file'),
filename: 'file.pdf',
# content type is optional
content_type: 'application/pdf'
)