SocioQuiz/socio_quiz

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

Summary

Maintainability
Test Coverage
<h1>Listing categories</h1>
<% if user_signed_in? && current_user.permission == "admin"%>
  <table>
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
        <th colspan="3"></th>
      </tr>
    </thead>

    <tbody>
      <% @categories.each do |category| %>
        <tr>
          <td><%= category.name %></td>
          <td><%= category.description %></td>
          <td><%= link_to 'Show', category %></td>
          <td><%= link_to 'Edit', edit_category_path(category) %></td>
          <td><%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' } %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
  <br>

  <%= link_to 'New Category', new_category_path %>
<% end %>