gitt/forum_monster

View on GitHub
lib/generators/forum_monster/templates/views/categories/index.html.erb

Summary

Maintainability
Test Coverage
<div class="right controls"><%= link_to "New Forum Category", new_category_path %></div>
<% @categories.each do |category| %>
  <div class="module">
    <div class="module_header">
      <%= category.title %>
      <span class="controls right smaller">
        <%= link_to "New Forum", new_forum_path %>
        <%= link_to "Edit Category", edit_category_path(category) %>
        <%= link_to "Delete Category", category_path(category), :confirm => "Are you sure you want to delete this category?", :method => :delete %>
      </span>
    </div>
    <% if category.forums.size > 0 %>
    <div>
      <table>
        <tr class="smaller">
          <th colspan="2" align="left">Forum</th>
          <th>Topics</th>
          <th>Posts</th>
          <th class="last_post" align="left">Last Post</th>
        </tr>
        <% category.forums.each do |forum| %>
        <tr>
          <td class="icon"><%= image_tag 'ruby.png' %></td>
          <td class="description">
            <%= link_to forum.title, forum_path(forum) %><br />
            <span class="smaller"><%= forum.description %></span><br />
          </td>
          <td class="counts smaller"><%= forum.topics.size %></td>
          <td class="counts smaller"><%= forum.posts.size - forum.topics.size %></td>
          <td class="last_post smaller">
            <% if forum.posts.size > 0 %>
              <%= forum.posts.last.created_at %><br />
              <%= forum.posts.last.user.username %>
            <% else %>
              No Topics / Posts
            <% end %>
          </td>
        </tr>
        <% end %>
      </table>
    </div>
    <% else %>
      <div class="module_body">There are currently no forums.</div>
    <% end %>
  </div>
<% end %>