Simplify new question form

In this form, the only case where `poll` might be present without
`question.poll` being present to is going to be the `new` action. We can
assign the poll in the `new` action and get rid of the `poll` variable
in the form.
This commit is contained in:
Javi Martín
2022-09-15 16:39:29 +02:00
parent d561a295e7
commit 4c8be42ea1
4 changed files with 5 additions and 7 deletions

View File

@@ -16,6 +16,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
@polls = Poll.all
proposal = Proposal.find(params[:proposal_id]) if params[:proposal_id].present?
@question.copy_attributes_from_proposal(proposal)
@question.poll = @poll
end
def create