nick-desteffen/mongoid-scribe

View on GitHub
app/views/mongoid/scribe/documents/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for :navigation do %>
  <%= link_to "All Documents", root_path, class: "button orange-button mobile-full" %>
  <%= link_to "New #{@klass.name}", new_document_path(model_param(@klass)), class: "button orange-button mobile-full" %>
<% end %>

<div class="section header">
  <div class="container clear">
    <h1 class='logo'><%= @klass.name.pluralize %></h1>
  </div>
</div>

<table>
  <thead>
    <tr>
      <% Mongoid::Scribe.index_for(@klass).each_pair do |header, config| %>
        <th><%= header.to_s.humanize %></th>
      <% end %>
      <th>Actions</th>
    </tr>
  </thead>
  <tbody>
    <% @documents.each do |document| %>
      <tr>
        <% Mongoid::Scribe.index_for(@klass).each_pair do |header, config| %>
          <td><%= Mongoid::Scribe::Builders::Table.new(document, header, config).cell %></td>
        <% end %>
        <td>
          <%= link_to "View", document_path(model_param(@klass), document) %> |
          <%= link_to "Edit", edit_document_path(model_param(@klass), document) %> |
          <%= link_to "Destroy", destroy_document_path(model_param(@klass), document), method: :delete, data: {confirm: "Are you sure you want to destroy this record?"} %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>