Fix broken file downloads

main
rebuilt 3 years ago
parent a173740ded
commit f2089c2eeb

@ -2,4 +2,9 @@ class ResearchController < ApplicationController
def index def index
end end
def download_pdf
send_file "#{Rails.root}/public/docs/#{params[:path]}.pdf", type: "application/pdf", x_sendfile: true
end
end end

@ -17,17 +17,17 @@
<div class="container px-5 my-5"> <div class="container px-5 my-5">
<div class="row gx-5 justify-content-center"> <div class="row gx-5 justify-content-center">
<div class="grid-container download-container"> <div class="grid-container download-container">
<%= link_to("Test Anxiety", download: asset_path("docs/test_anxiety_and_poor_sleep_2021.pdf"), target: "_blank") do %> <%= link_to(research_download_pdf_path(path: "test_anxiety_and_poor_sleep")) do %>
<%= image_tag "research/test_anxiety_and_sleep.png", class: "file-download" %> <%= image_tag "research/test_anxiety_and_sleep.png", class: "file-download" %>
<% end %> <% end %>
</div> </div>
<div class="grid-container download-container"> <div class="grid-container download-container">
<%= link_to("Psychological toll of high statkes testing", download: asset_path("docs/psychological_toll_of_high_stakes_testing_2022.pdf"), target: "_blank") do %> <%= link_to(research_download_pdf_path(path: "psychological_toll_of_high_stakes_testing")) do %>
<%= image_tag "research/psychological_toll_of_high_stakes_testing.png", class: "file-download" %> <%= image_tag "research/psychological_toll_of_high_stakes_testing.png", class: "file-download" %>
<% end %> <% end %>
</div> </div>
<div class="grid-container download-container"> <div class="grid-container download-container">
<%= link_to("Test Anxiety", download: asset_path("docs/testing_stress_and_performance.pdf"), target: "_blank") do %> <%= link_to( research_download_pdf_path(path: "testing_stress_and_performance")) do %>
<%= image_tag "research/testing_stress.png", class: "file-download" %> <%= image_tag "research/testing_stress.png", class: "file-download" %>
<% end %> <% end %>
</div> </div>

@ -6,6 +6,7 @@ Rails.application.routes.draw do
resources :qpa, only: :index resources :qpa, only: :index
resources :resource, only: :index resources :resource, only: :index
resources :research, only: :index resources :research, only: :index
get 'research/download_pdf', to: "research#download_pdf"
resources :work_with_ecp, only: :index resources :work_with_ecp, only: :index
resources :construction, only: :index resources :construction, only: :index
resources :district_leader, only: :index resources :district_leader, only: :index

Loading…
Cancel
Save