Im trying to display an attached pdf which is stored on Amazon S3 on the model's show
view, but I can't get it to work. So far my best attempt was to get the uploaded file's url on s3 like this :
#controller.rb
@key = upload.file.service_url
which successfully gets the URL of the file, and display it with iframe in the view. Which sadly doesn't work.
#view.html.erb
<iframe src=" <% @key %> " width="100%" height="500px">
It produces this:
My Upload
model:
class Upload < ApplicationRecord
belongs_to :user
has_one_attached :file
end
Thanks a lots
Your view.html.erb should be like this
#view.html.erb
<iframe src=<%= @key %> width="100%" height="500px"></iframe>
This (" <% @key %> ") is a string for rails basically
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.