rtopitt/bolao2014

View on GitHub
app/views/questions/show.html.erb

Summary

Maintainability
Test Coverage
<% content_for(:title) { "#{Question.model_name.human(count: 1)} ##{@question.number}" } %>

<div class="row">
  <div class="small-12 column">
    <h2><%= Question.model_name.human(count: 1) %> #<%= @question.number %></h2>
  </div>
</div>

<div class="question" id="<%= @question.css_id %>">
  <div class="row">
    <div class="small-12 column">
      <p><strong><%= @question.body %></strong></p>
      <p><%= Question.human_attribute_name(:answer) %>: <%= @question.answer_text_or_? %></p>
    </div>
  </div>
</div>

<div class="row">
  <div class="small-12 column">
    <% if admin_logged_in? %>
      <p><%= link_to t('.edit'), edit_admin_question_path(@question), class: 'admin-action' %></p>
    <% end %>
    <p><%= link_to t('.all'), questions_path %> | <%= @question.link_to_previous %> | <%= @question.link_to_next %></p>
  </div>
</div>

<div class="row">
  <div class="small-12 column">
    <h3><%= Bet.model_name.human(count: 2) %></h3>
  </div>
</div>

<div class="row">
  <div class="small-12 column">
    <table id="question_bets_table">
      <thead>
        <tr>
          <th class="text-left"><%= t('bets.show.better') %></th>
          <th class="text-center"><%= t('bets.show.answer') %></th>
          <th class="text-center"><%= t('bets.show.points') %></th>
        </tr>
      </thead>
      <tbody>
        <% @question.question_bets.each do |question_bet| %>
          <% bet = question_bet.bet %>
          <% user = bet.user %>
          <tr>
            <td>
              <a name="<%= bet.css_id %>"></a>
              <%= link_to user.name_or_email, bet_path(bet, anchor: @question.css_id) %>
            </td>
            <td class="text-left"><%= question_bet.answer_text_if_locked %></td>
            <td class="text-center"><%= question_bet.points_with_explanation %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>