Fix duplicate options

This commit is contained in:
Bernie Chiu 2014-01-21 16:19:16 +08:00 committed by Saurabh Bhatia
parent 77c00ac72f
commit d19223c873
1 changed files with 27 additions and 24 deletions

View File

@ -199,6 +199,7 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
end end
end end
end end
@survey.survey_questions.all.each do |question| @survey.survey_questions.all.each do |question|
new_question = @new_survey.survey_questions.new new_question = @new_survey.survey_questions.new
question.attributes.each do |key, value| question.attributes.each do |key, value|
@ -210,30 +211,32 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
end end
end end
end end
question.survey_question_options.all.each do |option|
new_option = new_question.survey_question_options.new # question.survey_question_options.all.each do |option|
option.attributes.each do |key, value| # new_option = new_question.survey_question_options.new
unless ['_id', 'survey_question_id'].include? key # option.attributes.each do |key, value|
if option.respond_to?(key + '_translations') # unless ['_id', 'survey_question_id'].include? key
new_option.send(key + '_translations=', value) # if option.respond_to?(key + '_translations')
else # new_option.name_translations = value
new_option.write_attribute(key, value) # else
end # new_option.write_attribute(key, value)
end # end
end # end
end # end
question.survey_question_radiogroups.all.each do |radiogroup| # end
new_radiogroup = new_question.survey_question_radiogroups.new
radiogroup.attributes.each do |key, value| # question.survey_question_radiogroups.all.each do |radiogroup|
unless ['_id', 'survey_question_id'].include? key # new_radiogroup = new_question.survey_question_radiogroups.new
if radiogroup.respond_to?(key + '_translations') # radiogroup.attributes.each do |key, value|
new_radiogroup.send(key + '_translations=', value) # unless ['_id', 'survey_question_id'].include? key
else # if radiogroup.respond_to?(key + '_translations')
new_radiogroup.write_attribute(key, value) # new_option.name_translations = value
end # else
end # new_radiogroup.write_attribute(key, value)
end # end
end # end
# end
# end
end end
@new_survey.create_user_id = current_user.id @new_survey.create_user_id = current_user.id