This way the code is easier to follow; the code checking whether the list has contents is in the partial rendering the list. We also remove some duplication setting up related content in the controllers. For some reason, we have to manually ignore i18n keys which were automatically ignored when the code was in the view.
22 lines
867 B
Plaintext
22 lines
867 B
Plaintext
<ul class="related-content-list" id="related-content-list">
|
|
<% related_contents.compact.each do |related| %>
|
|
<% related_content = related.find_related_content(relationable) %>
|
|
|
|
<li id="related-content-<%= related_content.id %>">
|
|
<div>
|
|
<span class="related-content-title"><%= t("related_content.content_title.#{related.model_name.singular}") %></span><br>
|
|
<h3 class="inline-block">
|
|
<%= link_to related.title, related.url %>
|
|
</h3>
|
|
</div>
|
|
<% if current_user && related_content.author != current_user && !related_content.scored_by_user?(current_user) %>
|
|
<span id="<%= dom_id(related_content) %>" class="js-score-actions score-actions">
|
|
<%= render "relationable/score", related: related_content %>
|
|
</span>
|
|
<% end %>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
|
|
<%= paginate related_contents %>
|