Handle more possible inputs for polls correct
This commit is contained in:
parent
f221a081dd
commit
aa44291b69
1 changed files with 4 additions and 2 deletions
|
@ -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|
|
||||||
|
|
Loading…
Reference in a new issue