1

我正在使用 Rails 3、ActiveAdmin 和 Kaminari。

我在documents.rb 文件(activeadmin 文件)上有这个。

collection_action :index do
  @page_title = "Documents"
  @shipments = Shipment.page(params[:id]).per(3)
  render '_invoices', :layout => 'active_admin'
end

分页链接显示正常。我单击分页链接,我确实在 URL 中得到了这个,http://localhost:3000/admin/documents?page=4所以看起来很好。问题是,它总是显示相同的记录,它们不会根据页面而改变。

这就是我所拥有的正在渲染的部分......

<table class="index_table">
  <tr>
    <th>File #</th>
    ... buncla th's
  </tr>
<% @shipments.each do |shipment| %>
  <tr class="<%= cycle("odd", "even") %>">
    <td><%= link_to shipment.file_number, admin_shipment_path(shipment) %></td>
    ...buncha cells...
  </tr>
<% end %>
</table>

<div id="index_footer"><%= paginate @shipments %></div>
4

1 回答 1

3

使用页面参数而不是 id。

@shipments = Shipment.page(params[:page]).per(3)

于 2012-01-19T18:13:58.210 回答