Fix creating a post with poll

There were validation errors because `answer.poll` wasn't set.
This commit is contained in:
Benjamin Neff 2017-08-06 00:37:18 +02:00
parent c382321934
commit 8a5752dd6c
No known key found for this signature in database
GPG key ID: 971464C3F1A90194

View file

@ -36,7 +36,8 @@ class StatusMessageCreationService
if params[:poll_question].present?
status_message.build_poll(question: params[:poll_question])
[*params[:poll_answers]].each do |poll_answer|
status_message.poll.poll_answers.build(answer: poll_answer)
answer = status_message.poll.poll_answers.build(answer: poll_answer)
answer.poll = status_message.poll
end
end
end