@@ -53,6 +53,8 @@ class Question < ApplicationRecord
5353 # inverse_of needed for nested forms
5454 has_many :question_options , dependent : :destroy , inverse_of : :question
5555
56+ has_many :question_identifiers , dependent : :destroy
57+
5658 has_many :annotations , dependent : :destroy , inverse_of : :question
5759
5860 has_and_belongs_to_many :themes , join_table : 'questions_themes'
@@ -101,6 +103,8 @@ class Question < ApplicationRecord
101103
102104 accepts_nested_attributes_for :question_options , allow_destroy : true ,
103105 reject_if : -> ( a ) { a [ :text ] . blank? }
106+
107+ accepts_nested_attributes_for :question_identifiers , allow_destroy : true
104108
105109 accepts_nested_attributes_for :annotations , allow_destroy : true ,
106110 reject_if : proc { |a | a [ :text ] . blank? && a [ :id ] . blank? }
@@ -121,6 +125,8 @@ def deep_copy(**options)
121125 copy . save! ( validate : false ) if options . fetch ( :save , false )
122126 options [ :question_id ] = copy . id
123127 question_options . each { |qo | copy . question_options << qo . deep_copy ( **options ) }
128+ # question_identifiers deep_copy bit
129+ question_identifiers . each { |qi | copy . question_identifiers << qi . deep_copy ( **options ) }
124130 annotations . each do |annotation |
125131 copy . annotations << annotation . deep_copy ( **options )
126132 end
0 commit comments