Move the summing logic from the template into the component. Introduce a votes_for(option) method that looks up grouped partial results and returns the total amount or 0.
20 lines
600 B
Plaintext
20 lines
600 B
Plaintext
<div class="admin-poll-results-question">
|
|
<h3><%= question.title %></h3>
|
|
<table class="margin">
|
|
<thead>
|
|
<tr>
|
|
<th><%= t("admin.results.result.table_answer") %></th>
|
|
<th class="text-center"><%= t("admin.results.result.table_votes") %></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% question.question_options.each_with_index do |option, i| %>
|
|
<tr id="question_<%= question.id %>_<%= i %>_result">
|
|
<td><%= option.title %></td>
|
|
<td class="text-center"><%= votes_for(option) %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|