controllers: use template: rather than file: to render PDFs

ActionView now throws an error if a relative path is used with `file:`.
This commit is contained in:
Pierre de La Morinerie 2021-02-17 18:02:31 +00:00
parent 185c74d891
commit 3f3d6ae399
5 changed files with 6 additions and 6 deletions

View file

@ -3,7 +3,7 @@ class API::V2::DossiersController < API::V2::BaseController
def pdf
@include_infos_administration = true
render(file: 'dossiers/show', formats: [:pdf])
render(template: 'dossiers/show', formats: [:pdf])
end
def geojson

View file

@ -42,7 +42,7 @@ module Instructeurs
respond_to do |format|
format.pdf do
@include_infos_administration = true
render(file: 'dossiers/show', formats: [:pdf])
render(template: 'dossiers/show', formats: [:pdf])
end
format.all
end
@ -235,7 +235,7 @@ module Instructeurs
def generate_pdf_for_instructeur_export
@include_infos_administration = true
pdf = render_to_string(file: 'dossiers/show', formats: [:pdf])
pdf = render_to_string(template: 'dossiers/show', formats: [:pdf])
dossier.pdf_export_for_instructeur.attach(io: StringIO.open(pdf), filename: "export-#{dossier.id}.pdf", content_type: 'application/pdf')
end

View file

@ -82,7 +82,7 @@ module Users
def generate_empty_pdf(procedure)
@dossier = procedure.new_dossier
s = render_to_string(file: 'dossiers/dossier_vide', formats: [:pdf])
s = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf])
send_data(s, :filename => "#{procedure.libelle}.pdf")
end
end

View file

@ -32,7 +32,7 @@ module Users
respond_to do |format|
format.pdf do
@include_infos_administration = false
render(file: 'dossiers/show', formats: [:pdf])
render(template: 'dossiers/show', formats: [:pdf])
end
format.all
end

View file

@ -121,7 +121,7 @@ class AttestationTemplate < ApplicationRecord
def build_pdf(dossier)
attestation = render_attributes_for(dossier: dossier)
attestation_view = ApplicationController.render(
file: 'new_administrateur/attestation_templates/show',
template: 'new_administrateur/attestation_templates/show',
formats: :pdf,
assigns: { attestation: attestation }
)