แนบไฟล์เข้า ActiveStorage โดยไม่ผ่าน HTTP
13 ตุลาคม 2563
ถ้าคุณต้องการแนบไฟล์ที่สร้างไว้บนดิสก์ หรือไฟล์ที่ดาวน์โหลดมาจาก URL ที่ผู้ใช้ส่งเข้ามา ทำได้แบบนี้
@model.image.attach(
io: File.open('/path/to/file'),
filename: 'file.pdf',
# content type is optional
content_type: 'application/pdf'
)