Is there a way for Trix editor (or ActionText) to display a link of the file attached so people could download it instead of showing a preview of the file? My example attachment is a PDF.
Asked
Active
Viewed 894 times
1 Answers
2
You can edit it in the _blob.html.erb
file,
for example:
<span class="attachment__download"><%= link_to blob.filename, rails_blob_path(blob) %></span>
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
Because action text will use this _blob.html.erb
file for rendering the attachment file you upload, you can do anything in here with object blob
(ActiveStorage::Blob)
For more information
https://api.rubyonrails.org/classes/ActiveStorage/Preview.html https://edgeapi.rubyonrails.org/classes/ActiveStorage/Blob.html

elarcoiris
- 1,914
- 4
- 28
- 30

Phạm Ngọc Hoàng
- 36
- 2