demarches-normaliennes/app/models/concerns/dossier_prefillable_concern.rb

16 lines
387 B
Ruby
Raw Normal View History

2022-11-28 15:54:14 +01:00
# frozen_string_literal: true
module DossierPrefillableConcern
2022-11-28 15:54:14 +01:00
extend ActiveSupport::Concern
def prefill!(champs_public_attributes)
return unless champs_public_attributes.any?
attr = { prefilled: true }
2023-02-03 12:14:18 +01:00
attr[:champs_public_all_attributes] = champs_public_attributes.map { |h| h.merge(prefilled: true) }
2022-11-28 15:54:14 +01:00
assign_attributes(attr)
2022-11-28 15:54:14 +01:00
save(validate: false)
end
end