models: require belong_to associations on type_de_champ
- Make `type_de_champ.procedure` a requirement; - Move the procedure_id assignation to `before_validation` (otherwise the record is invalid, and never gets saved);
This commit is contained in:
parent
6328011f60
commit
5a7bd24fba
3 changed files with 6 additions and 4 deletions
|
@ -49,7 +49,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
repetition: 'repetition'
|
||||
}
|
||||
|
||||
belongs_to :procedure
|
||||
belongs_to :procedure, optional: false
|
||||
belongs_to :revision, class_name: 'ProcedureRevision', optional: true
|
||||
|
||||
belongs_to :parent, class_name: 'TypeDeChamp', optional: true
|
||||
|
@ -73,8 +73,8 @@ class TypeDeChamp < ApplicationRecord
|
|||
serialize :options, WithIndifferentAccess
|
||||
|
||||
after_initialize :set_dynamic_type
|
||||
before_validation :setup_procedure
|
||||
after_create :populate_stable_id
|
||||
before_save :setup_procedure
|
||||
|
||||
attr_reader :dynamic_type
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue