allows users to change their vote without refreshing the page

This commit is contained in:
rgarcia
2017-10-02 13:14:58 +02:00
parent c3d5041717
commit b623422805
3 changed files with 46 additions and 4 deletions

View File

@@ -14,6 +14,6 @@ class Poll::Answer < ActiveRecord::Base
scope :by_question, ->(question_id) { where(question_id: question_id) }
def record_voter_participation
Poll::Voter.create!(user: author, poll: poll)
Poll::Voter.find_or_create_by!(user: author, poll: poll)
end
end