diff --git a/app/models/champs/rna_champ.rb b/app/models/champs/rna_champ.rb index 26deed948..176d91152 100644 --- a/app/models/champs/rna_champ.rb +++ b/app/models/champs/rna_champ.rb @@ -23,7 +23,7 @@ class Champs::RNAChamp < Champ validates :value, allow_blank: true, format: { with: /\AW[0-9]{9}\z/, message: I18n.t(:not_a_rna, scope: 'activerecord.errors.messages') } - after_validation :update_external_id, if: -> { value.present? && external_id.blank? } + after_validation :update_external_id, if: -> { value_changed? } delegate :id, to: :procedure, prefix: true @@ -44,6 +44,6 @@ class Champs::RNAChamp < Champ end def update_external_id - update(external_id: value) + self.external_id = self.value end end