demarches-normaliennes/app/models/concerns/dossier_prefillable_concern.rb
Sébastien Carceles 0046338e6a
fix(prefill): don't mark the dossier as prefilled when it's not (#8464)
A dossier should not be marked as prefilled when it's not, meaning
when no prefill params are given.
2023-01-19 10:51:56 +00:00

15 lines
383 B
Ruby

# frozen_string_literal: true
module DossierPrefillableConcern
extend ActiveSupport::Concern
def prefill!(champs_public_attributes)
return unless champs_public_attributes.any?
attr = { prefilled: true }
attr[:champs_public_attributes] = champs_public_attributes.map { |h| h.merge(prefilled: true) }
assign_attributes(attr)
save(validate: false)
end
end