|
|
|
@ -46,9 +46,9 @@ class PollVotesController < ApplicationController
|
|
|
|
|
if question_answer_ids.present?
|
|
|
|
|
if question_answer_text.present? #有文字输入,但是不存在其他选项的
|
|
|
|
|
ques_vote_id = question_answer_ids.map(&:to_i).max
|
|
|
|
|
if user_votes.find_vote_text.present?
|
|
|
|
|
current_vote_text = user_votes.find_vote_text.first
|
|
|
|
|
current_vote_text.update_attribute("vote_text", question_answer_text)
|
|
|
|
|
ques_vote = user_votes.find_by(poll_answer_id: ques_vote_id)
|
|
|
|
|
if ques_vote.present?
|
|
|
|
|
ques_vote.update_attribute!("vote_text", question_answer_text)
|
|
|
|
|
else
|
|
|
|
|
answer_option = {
|
|
|
|
|
:user_id => current_user.id,
|
|
|
|
@ -56,7 +56,7 @@ class PollVotesController < ApplicationController
|
|
|
|
|
:poll_answer_id => ques_vote_id,
|
|
|
|
|
:vote_text => question_answer_text
|
|
|
|
|
}
|
|
|
|
|
PollVote.create(answer_option)
|
|
|
|
|
PollVote.create!(answer_option)
|
|
|
|
|
# 重新取一次poll_votes
|
|
|
|
|
user_votes = @poll_question.poll_votes.find_current_vote("user_id",current_user.id)
|
|
|
|
|
end
|
|
|
|
|