rubyforgood/babywearing

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

Summary

Maintainability
Test Coverage
<div class="card">
  <header class="card-header d-flex align-items-center">
    <h3 class="mr-auto">Categories</h3>
    <% if policy(:category).new? %>
      <%= link_to '+ New', new_category_path, class: "btn btn-primary" %>
    <% end %>
  </header>

  <section>
    <table class="table">
      <thead>
        <tr>
          <th scope="col">Name</th>
          <th scope="col">Description</th>
          <th scope="col"></th>
        </tr>
      </thead>
      <tbody>
        <% @categories.includes(:subcategories).each do |category| %>
          <%= render 'category', category: category %>
        <% end %>
      </tbody>
    </table>
  </section>
</div>