Activeadmin:将部分添加到索引的末尾作为块

Activeadmin: Adding partial to end of index as block

我正在尝试通过将模态部分呈现到页面上来向我的索引页添加模态。每当我添加部分时,它都会添加 30 次,每条记录显示 1 次。这仅在我执行 index as: :block.

时发生

这是我的代码:

  index as: :block, download_links: true do |ticket|
    div :for => ticket, class: "ticket #{ticket.current_state}" do
      resource_selection_cell(ticket) if authorized?(:export, ticket)
      render ticket, actions: true
    end
    render partial: 'resolve_modal'
  end

_resolve_modal.html.erb

<!-- Modal -->
<div class="modal fade" id="resolve-modal" tabindex="-1" role="dialog" aria-labelledby="resolve-modal" aria-hidden="true">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="resolve-modal-title">Resolve</h4>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      </div>
        <div class="modal-body text-left">
          <div class="text-center alert status"></div>
          <div class="form-group">
            <label for="resolution">Resolution</label>
            <textarea class="form-control" id="resolution" rows="3"></textarea>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary" id="resolve-button">Resolve</button>
        </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

同样,它显示了 30 次模态。我只希望它出现在源代码中 1 次。有人可以帮忙吗?

您可以这样做的一种方法是 defining your own custom index, subclassing ActiveAdmin::Views::IndexAsBlock and adding your modal to the build method 在遍历集合之后。