Fix update external id after validation
This commit is contained in:
parent
4ce6cd0072
commit
e694ff1f60
1 changed files with 2 additions and 2 deletions
|
@ -23,7 +23,7 @@ class Champs::RNAChamp < Champ
|
||||||
validates :value, allow_blank: true, format: {
|
validates :value, allow_blank: true, format: {
|
||||||
with: /\AW[0-9]{9}\z/, message: I18n.t(:not_a_rna, scope: 'activerecord.errors.messages')
|
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
|
delegate :id, to: :procedure, prefix: true
|
||||||
|
|
||||||
|
@ -44,6 +44,6 @@ class Champs::RNAChamp < Champ
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_external_id
|
def update_external_id
|
||||||
update(external_id: value)
|
self.external_id = self.value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue