hello-gem/hello

View on GitHub
app/views/hello/authentication/sessions.html.erb

Summary

Maintainability
Test Coverage
<h1>Switch Accounts</h1>

<table class="table table-condensed">
  <thead>
    <tr>
      <th>Username</th>
      <th>Name</th>
      <th>Role</th>
      <th>Expiry</th>
      <th colspan="2">Actions</th>
    </tr>
  </thead>

  <tbody>
    <% @accesses.each do |a| %>
      <tr>
        <td><%= link_to a.user.username, a.user %></td>
        <td><%= a.user.name %></td>
        <td><%= a.user.role %></td>
        <td><%= distance_of_time_in_words_to_now(a.expires_at) %></td>
        <td><%= link_to "Switch!",
                        hello.session_path(a.id),
                        class: 'btn btn-xs btn-block btn-success' unless is_current_access?(a) %></td>
        <td><%= button_to "Forget",
                          hello.session_path(a.id),
                          method: :delete,
                          class: 'btn btn-xs btn-block btn-danger',
                          data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
    <tr>
      <td colspan="4"></td>
      <td colspan="2"><%= link_to "Add Account", hello.new_session_path, class: 'btn btn-xs btn-block btn-info' %></td>
    </tr>
  </tbody>
</table>