I am working on Rails application
where uploaded PDF
using Paperclip Gem
. Now try to display PDF
using below HTML code.
Upload PDF settings
has_attached_file :agreement
validates_attachment_content_type :agreement, :content_type =>["application/pdf"]
<iframe src="/system/contracts/agreements/000/000/022/original/pdf_ag.pdf" align="middle" style="width: 100%; height:720px;" frameborder="0"></iframe>
But got error below
error : ActionView::MissingTemplate (Missing template sessions/unknown_route, application/unknown_route
No route matches [GET] "/system/contracts/agreements/000/000/022/original/pdf_ag.pdf"
I tried but same issue again and again. Let me know if any one have idea or trick.
Thanks
First of all, static content path, for regular Rails app, starts with /public
so /public/system/contracts/agreements/
and so on..
Make sure that your app, in the specific env where you're getting the error, handles static files ( config.serve_static_assets = true
for Rails < 5 and config.public_file_server.enabled = true
for Rails >= 5).
Also I'd advise to use absolute path instead of relative. It offers you more flexibility in case you decide to delegate your static files to nginx or CDN server OR you're requesting this PDF from iFrame on the domain different that current app.
I store PDF files
in public folder
and access it. It's work for me.
Thanks for your supports.
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.