ChaelCodes/HuntersKeepers

View on GitHub
app/views/playbooks/index.html.erb

Summary

Maintainability
Test Coverage
<h1><%= t('.title') %></h1>

<table class="table" title="<%= t('.title') %>" id="playbooks">
  <thead>
    <tr>
      <th><%= Playbook.human_attribute_name(:name) %></th>
      <% unless mobile_device? %>
        <th><%= Playbook.human_attribute_name(:description) %></th>
      <% end %>
      <th colspan="2"></th>
    </tr>
  </thead>

  <tbody>
    <% @playbooks.each do |playbook| %>
      <tr>
        <td><%= link_to playbook, playbook %></td>
        <% unless mobile_device? %>
          <td><%= playbook.description.truncate(100, separator: ' ') %></td>
        <% end %>
        <td>
          <% if policy(playbook).edit? %>
            <%= link_to t('.edit'), edit_playbook_path(playbook) %>
          <% end %>
        </td>
        <td>
          <% if policy(playbook).destroy? %>
            <%= link_to t('.destroy'), playbook, method: :delete, data: { confirm: t('.confirm_destroy') } %>
          <% end %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
<% if policy(Playbook).create? %>
  <%= link_to t('.new'), new_playbook_path %>
<% end %>