diff --git a/app/views/polls/questions/_question.html.erb b/app/components/polls/questions/question_component.html.erb similarity index 100% rename from app/views/polls/questions/_question.html.erb rename to app/components/polls/questions/question_component.html.erb diff --git a/app/components/polls/questions/question_component.rb b/app/components/polls/questions/question_component.rb new file mode 100644 index 000000000..d1a4edf27 --- /dev/null +++ b/app/components/polls/questions/question_component.rb @@ -0,0 +1,7 @@ +class Polls::Questions::QuestionComponent < ApplicationComponent + attr_reader :question + + def initialize(question:) + @question = question + end +end diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index ee4449124..29904041c 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -31,9 +31,7 @@ <% end %> <% end %> - <% @questions.each do |question| %> - <%= render "polls/questions/question", question: question %> - <% end %> + <%= render Polls::Questions::QuestionComponent.with_collection(@questions) %>