Check if user has voted before sign in
This commit is contained in:
@@ -41,4 +41,8 @@ module PollsHelper
|
|||||||
booth.name + location
|
booth.name + location
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def voted_before_sign_in(question)
|
||||||
|
current_user.current_sign_in_at >= question.poll.voters.find_by_user_id(current_user).updated_at
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="poll-question-answers">
|
<div class="poll-question-answers">
|
||||||
<% if can? :answer, question %>
|
<% if can? :answer, question %>
|
||||||
<% question.question_answers.each do |answer| %>
|
<% question.question_answers.each do |answer| %>
|
||||||
<% if @answers_by_question_id[question.id] == answer.title %>
|
<% if @answers_by_question_id[question.id] == answer.title && !voted_before_sign_in(question) %>
|
||||||
<span class="button answered"
|
<span class="button answered"
|
||||||
title="<%= t("poll_questions.show.voted", answer: answer.title)%>">
|
title="<%= t("poll_questions.show.voted", answer: answer.title)%>">
|
||||||
<%= answer.title %>
|
<%= answer.title %>
|
||||||
|
|||||||
Reference in New Issue
Block a user