From 102226efdf58584d941bc96665ce8309b4ccc234 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 12:32:00 +0800 Subject: [PATCH] fix bug --- app/controllers/poll_votes_controller.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index 813e35bba..f1da3a1b2 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -134,17 +134,11 @@ class PollVotesController < ApplicationController end def check_answer_in_question - # poll_answer_ids = @poll_question.poll_answers.pluck(:id) - # if @poll_question.question_type == 1 #单选题/多选题 - # unless (params[:poll_answer_id].present? && poll_answer_ids.include?(params[:poll_answer_id].to_i)) || (params[:poll_answer_id].blank? && params[:vote_text].present?) - # normal_status(-1, "答案ID错误!") - # end - # end poll_user_status = @poll.get_poll_status(current_user.id) poll_user = @poll.poll_users.find_by(user_id: current_user.id) #当前用户 question_type = @poll_question&.question_type - if [1,2].include?(question_type) && params[:poll_answer_id].blank? + if (question_type == 1) && params[:poll_answer_id].blank? normal_status(-1,"答案ID错误!") elsif question_type == 2 user_vote_count = params[:poll_answer_id].size @@ -153,7 +147,7 @@ class PollVotesController < ApplicationController else question_max_choices = 0 end - if question_max_choices > 0 && user_vote_count > question_max_choices + if question_max_choices > 0 && (user_vote_count > question_max_choices) normal_status(-1,"多选题答案超过最大限制!") end elsif (poll_user.present? && poll_user.commit_status == 1) || poll_user_status == 3