Skip to content

Commit

Permalink
Add "Download blank" link on form show page
Browse files Browse the repository at this point in the history
  • Loading branch information
jrunningen committed Apr 4, 2015
1 parent 6596af0 commit 21d1e64
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/controllers/housing_forms_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/views/housing_forms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<%= @housing_form.location %>
</p>

<%= 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 %>

Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 21d1e64

Please sign in to comment.