hello-gem/hello

View on GitHub
app/views/hello/management/accesses.html.erb

Summary

Maintainability
Test Coverage
<div class="row">

<%= render '/hello/shared/settings' %>

<div class="col-sm-3-offset col-md-2-offset col-sm-9 col-md-10">

<table class="table table-condensed">
  <thead>
    <tr>
      <th>#</th>
      <th>Device</th>
      <th>IP Address</th>
      <th></th>
    </tr>
  </thead>
  <tbody>


    <% @accesses.each_with_index do |access, i| %>
      <% is_current_access?(access).tap do |is_current_access| %>

        <tr class="<%= 'success' if is_current_access %>">
          <td>Device #<%= i+1 %></td>
          <td><%= access.full_device_name %></td>
          <td><%= access.ip %></td>
          <td>
            <% if is_current_access %>
              [this device]
            <% else %>
              <%= button_to 'Unlink',
                            access,
                            method: :delete,
                            class: 'btn btn-danger',
                            data: { confirm: 'Are you sure?' } %>
            <% end %>
          </td>
        </tr>

      <% end %>
    <% end %>


  </tbody>
</table>

</div>
</div>