33fa40eda2
Cleaning the value is useless, when fetching the association, as the value will be re-written by the dossier update, when the user fills in the dossier. Furthermore we need the value to persist when prefilling the champ.
18 lines
485 B
Ruby
18 lines
485 B
Ruby
module RNAChampAssociationFetchableConcern
|
|
extend ActiveSupport::Concern
|
|
|
|
def fetch_association!(rna)
|
|
data = APIEntreprise::RNAAdapter.new(rna, procedure_id).to_params
|
|
update!(data: data, value: rna)
|
|
nil
|
|
rescue APIEntreprise::API::Error, ActiveRecord::RecordInvalid => error
|
|
self.data = nil
|
|
self.value = rna
|
|
save(validate: false)
|
|
if error.try(:network_error?) && !APIEntrepriseService.api_up?
|
|
:network_error
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
end
|