tnantoka/konnyaku

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

Summary

Maintainability
Test Coverage
<% title = t(:list_posts) %>
<% 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>
    <% @paginated_posts.each do |post| %>
    <tr>
      <td><%= link_to "#{post.title(current_lang)}", post %></td>


      <td><%= link_to(post.category.name(current_lang), post.category) %></td>

      <td>
        <ul class="unstyled inline">
          <%= lang_list(post) %>
        </ul>
      </td>
    
      <% if user_signed_in? %>
      <td>
        <div class="btn-group">
        <%= link_to edit_post_path(post), class: 'btn btn-small', title: t(:edit) do %>
          <i class="icon-pencil"></i>
          <%= t(:edit) %>
        <% end %>

        <%= link_to post, method: :delete, data: { confirm: t(:sure) }, class: 'btn btn-danger btn-small', title: t(:delete) do %>
          <i class="icon-remove"></i>
          <%= t(:delete) %>
        <% end %>

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

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

<%= page_entries_info(@paginated_posts, entry_name: Post.model_name.human) %>
<%= paginate @paginated_posts, param_name: :p %>

<%= render 'links' %>