diff --git a/app/components/admin/poll/questions/form_component.html.erb b/app/components/admin/poll/questions/form_component.html.erb index 09c9ba9ad..34193725f 100644 --- a/app/components/admin/poll/questions/form_component.html.erb +++ b/app/components/admin/poll/questions/form_component.html.erb @@ -8,9 +8,7 @@
- <% if poll.present? %> - <%= f.hidden_field :poll_id, value: poll.id %> - <% elsif question.poll.present? %> + <% if question.poll.present? %> <%= f.hidden_field :poll_id, value: question.poll.id %> <% else %>
diff --git a/app/components/admin/poll/questions/form_component.rb b/app/components/admin/poll/questions/form_component.rb index 25507c284..4930c984e 100644 --- a/app/components/admin/poll/questions/form_component.rb +++ b/app/components/admin/poll/questions/form_component.rb @@ -1,10 +1,9 @@ class Admin::Poll::Questions::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper - attr_reader :poll, :question, :url + attr_reader :question, :url - def initialize(poll, question, url:) - @poll = poll + def initialize(question, url:) @question = question @url = url end diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 598e664e7..ea133c65f 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -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 diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index fb792c3de..c1254b5ca 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -1 +1 @@ -<%= render Admin::Poll::Questions::FormComponent.new(@poll, @question, url: form_url) %> +<%= render Admin::Poll::Questions::FormComponent.new(@question, url: form_url) %>