models: render attestations in a simpler way
The older method of instanciating an entire new rendering stack can be made simpler using Rails >= 5.0 methods. See https://api.rubyonrails.org/classes/ActionController/Renderer.html#method-i-render
This commit is contained in:
parent
a088b240e0
commit
8962db38cc
2 changed files with 13 additions and 7 deletions
|
@ -109,8 +109,11 @@ class AttestationTemplate < ApplicationRecord
|
|||
|
||||
def build_pdf(dossier)
|
||||
attestation = render_attributes_for(dossier: dossier)
|
||||
action_view = ActionView::Base.new(ActionController::Base.view_paths, attestation: attestation)
|
||||
attestation_view = action_view.render(file: 'new_administrateur/attestation_templates/show', formats: [:pdf])
|
||||
attestation_view = ApplicationController.render(
|
||||
file: 'new_administrateur/attestation_templates/show',
|
||||
formats: :pdf,
|
||||
assigns: { attestation: attestation }
|
||||
)
|
||||
|
||||
StringIO.new(attestation_view)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue