<% object_with_attachments.attachments.each do |attachment| %>
  <%= content_tag_for(:div, attachment, class: "attachment embedded") do %>
    <%= link_to(url: attachment.url) do %>
      <% if attachment.pdf? %>
        <%= image_tag(attachment.url(:thumbnail), alt: "") %>
      <% else %>
        <%= image_tag('pub-cover.png', alt: "") %>
      <% end %>
      <span class="visuallyhidden">Download </span><%= attachment.title %>
    <% end %>
    <dl class="attachment-metadata">
      <dt>Type</dt>
      <dd><%= humanized_content_type(attachment.file_extension) %></dd>
      <dt>Size</dt>
      <dd><%= number_to_human_size(attachment.file_size) %></dd>
      <% if attachment.number_of_pages.present? %>
        <dt>Length</dt>
        <dd><%= pluralize(attachment.number_of_pages, "page") %></dd>
      <% end %>
    </dl>
    <% unless attachment.accessible? %>
      <strong class="accessibility-warning">This file may not be accessible</strong>
    <% end %>
  <% end %>
<% end %>

<% object_with_attachments.attachments.each do |attachment| %>
  <%= render partial: "attachment" %>
<% end %>

Refactor attachments partial to just include attachment
Refactor attachments partial to just include attachment
