app/controllers/patients_controller.rb
# download a filled out pledge form based on patient record
download a filled out pledge form based on patient record
download a filled out pledge form based on patient record
def download
    if params[:case_manager_name].blank?
      flash[:alert] = "You need to enter your name in the box to sign and download the pledge"
      redirect_to edit_patient_path @patient
    else
      now = Time.zone.now.strftime('%Y%m%d')
      pdf_filename = "#{@patient.name}_pledge_form_#{now}.pdf"
      pdf = PledgeFormGenerator.new(current_user,
                                    @patient,
                                    params[:case_manager_name].to_s)
                               .generate_pledge_pdf
      @patient.update pledge_generated_at: Time.zone.now,
                      pledge_generated_by: current_user
      send_data pdf.render, filename: pdf_filename, type: 'application/pdf'
    end
  end
def download if params [ :case_manager_name ] . blank? flash [ :alert ] = "You need to enter your name in the box to sign and download the pledge" redirect_to edit_patient_path @patient else now = Time . zone . now . strftime ( '%Y%m%d' ) pdf_filename = "#{@patient.name}_pledge_form_#{now}.pdf" pdf = PledgeFormGenerator . new ( current_user , @patient , params [ :case_manager_name ] . to_s ) . generate_pledge_pdf @patient . update pledge_generated_at : Time . zone . now , pledge_generated_by : current_user send_data pdf . render , filename : pdf_filename , type : 'application/pdf' end end
download a filled out pledge form based on patient record
download a filled out pledge form based on patient record