app/controllers/questionnaires_controller.rb
# Handles questions whose wording changed as a result of the edit
# @param [Object] questionnaire_id
Handles questions whose wording changed as a result of the edit
Handles questions whose wording changed as a result of the edit
def save_questions(questionnaire_id)
    delete_questions questionnaire_id
    save_new_questions questionnaire_id
    if params[:question]
      for question_key in params[:question].keys
        if params[:question][question_key][:txt].strip.empty?
          Question.delete(question_key)
        else
          question = Question.find(question_key)
          Rails.logger.info(question.errors.messages.inspect) unless question.update_attributes(params[:question][question_key])
          end
      end
    end
  end
def save_questions ( questionnaire_id ) delete_questions questionnaire_id save_new_questions questionnaire_id if params [ :question ] for question_key in params [ :question ] . keys if params [ :question ] [ question_key ] [ :txt ] . strip . empty? Question . delete ( question_key ) else question = Question . find ( question_key ) Rails . logger . info ( question . errors . messages . inspect ) unless question . update_attributes ( params [ :question ] [ question_key ] ) end end end end
Handles questions whose wording changed as a result of the edit
Handles questions whose wording changed as a result of the edit
# question text is empty, delete the question # Update existing question.
questionnaire_id
None