tnantoka/konnyaku

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

Summary

Maintainability
Test Coverage
<% title = t(:list_categories) %>
<% content_for(:title) { title } %>

<div class="page-header">
  <h1><%= title %></h1>
</div>

<table class="table-condensed <%= 'table table-striped table-hover' if user_signed_in? %>">
  <tbody>
    <% @categories.each do |category| %>
    <tr>
      <td><%= link_to "#{category.name(current_lang)} (#{category.posts.count})", category %></td>
    
      <% if user_signed_in? %>
      <td>
        <div class="btn-group">
        <%= link_to edit_category_path(category), class: 'btn btn-small', title: t(:edit) do %>
          <i class="icon-pencil"></i>
          <%= t(:edit) %>
        <% end %>

        <% if category != @categories.first %>
        <%= link_to category, method: :delete, data: { confirm: t(:sure) }, class: 'btn btn-danger btn-small', title: t(:delete) do %>
          <i class="icon-remove"></i>
          <%= t(:delete) %>
        <% end %>
        <% end %>

        </div>
      </td>
      <% end %>

    </tr>
    <% end %>
  </tbody>
</table>

<%= render 'links' %>