I need to add a link to download the file from assets/docs/Физика.pdf I do not know how to do that. I am trying to do so here: in view -
<%= link_to "download", '/Физика.pdf', :download => 'filename' %>
I get an error message:
No route matches [GET] "/%D0%A4%D0%B8%D0%B7%D0%B8%D0%BA%D0%B0.pdf"
What am I doing wrong? Help me please
You can do steps as below:
Step1: Open file routes.rb
get 'download_pdf', to: "homes#download_pdf"
Step2: I assumed your controller
was home_controller.rb
, you put this line:
def download_pdf
send_file "#{Rails.root}/app/assets/docs/Физика.pdf", type: "application/pdf", x_sendfile: true
end
Step3: In your view
file.
<%= link_to "download", download_pdf_path %>
I suggest that you should put this docs
folder in public
folder.
For example:
public/docs/*.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With