From 21d1e64d4a144b192cb3150567810da264b2b75d Mon Sep 17 00:00:00 2001 From: Jeff Runningen Date: Sat, 4 Apr 2015 11:56:45 -0400 Subject: [PATCH] Add "Download blank" link on form show page --- app/controllers/housing_forms_controller.rb | 9 ++++++++- app/views/housing_forms/show.html.erb | 2 ++ config/routes.rb | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/housing_forms_controller.rb b/app/controllers/housing_forms_controller.rb index db0ec738..535dad66 100644 --- a/app/controllers/housing_forms_controller.rb +++ b/app/controllers/housing_forms_controller.rb @@ -1,6 +1,6 @@ class HousingFormsController < ApplicationController skip_before_action :authenticate_user!, only: [:index, :show] - before_action :set_housing_form, only: [:show, :edit, :update, :destroy, :download] + before_action :set_housing_form, only: [:show, :edit, :update, :destroy, :download, :download_bank] before_action :set_applicant, only: [:show, :index, :download] # GET /housing_forms @@ -75,6 +75,13 @@ def download filename: download_filename) end + def download_blank + @housing_form = HousingForm.find(params[:id]) + send_file(@housing_form.path, + type: 'application/pdf', + filename: "#{Slugify.slugify(@housing_form.name)}.pdf") + end + private # Use callbacks to share common setup or constraints between actions. def set_housing_form diff --git a/app/views/housing_forms/show.html.erb b/app/views/housing_forms/show.html.erb index 822ecf5c..d6bab1a9 100644 --- a/app/views/housing_forms/show.html.erb +++ b/app/views/housing_forms/show.html.erb @@ -12,6 +12,8 @@ <%= @housing_form.location %>

+ <%= link_to 'Download filled', download_housing_form_path(@housing_form) %> | + <%= link_to 'Download blank', download_blank_housing_form_path(@housing_form) %> | <%= link_to 'Edit', edit_housing_form_path(@housing_form) %> | <%= link_to 'Back', housing_forms_path %> diff --git a/config/routes.rb b/config/routes.rb index 549dd81e..6d4550ef 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,6 +37,7 @@ resources :salesforce_applicants get '/download/:id', to: 'housing_forms#download', as: 'download_housing_form' + get '/download/blank/:id', to: 'housing_forms#download_blank', as: 'download_blank_housing_form' get "home/index" get "/pdf_guide", to: "pdf_guide#index" get "/dictionary", to: "dictionary#index"