Handle more possible inputs for polls correct

This commit is contained in:
Patrick Gansterer 2020-08-12 13:43:28 +02:00
parent f221a081dd
commit aa44291b69

View file

@ -76,9 +76,11 @@ class PollsController < ApplicationController
@poll_vote.update!(note: params[:note], user: current_user) @poll_vote.update!(note: params[:note], user: current_user)
if @poll.single_select? if @poll.single_select?
choices = { params[:choice] => '1' } choices = {}
choice = params[:choice]
choices[choice] = '1' if choice
else else
choices = params[:choices] || {} choices = params[:choices].try(:to_h) || {}
end end
@poll_vote.poll_choices = choices.map do |choice, value| @poll_vote.poll_choices = choices.map do |choice, value|