Add read more links to poll question component

This commit is contained in:
decabeza
2022-09-09 13:20:55 +02:00
committed by Senén Rodero Rodríguez
parent 88007d0c5d
commit 1eb52fb045
5 changed files with 33 additions and 0 deletions

View File

@@ -12,4 +12,11 @@
<div id="<%= dom_id(question) %>_answers" class="padding">
<%= render Polls::Questions::AnswersComponent.new(question) %>
</div>
<% if question.answers_with_read_more? %>
<div>
<p><%= t("poll_questions.read_more_about") %></p>
<p><%= answers_read_more_links %></p>
</div>
<% end %>
</div>

View File

@@ -4,4 +4,10 @@ class Polls::Questions::QuestionComponent < ApplicationComponent
def initialize(question:)
@question = question
end
def answers_read_more_links
safe_join(question.answers_with_read_more.map do |answer|
link_to answer.title, "#answer_#{answer.id}"
end, ", ")
end
end