Rails 3. Kaminari 显示分页链接但不更改记录
我正在使用 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>
I'm using Rails 3, ActiveAdmin and Kaminari.
I have this on the documents.rb file (activeadmin file).
collection_action :index do
@page_title = "Documents"
@shipments = Shipment.page(params[:id]).per(3)
render '_invoices', :layout => 'active_admin'
end
The pagination links are displayed fine. I click the pagination links and I do get this in the URL http://localhost:3000/admin/documents?page=4
so it seems fine. The problem is, it always displays the same records, they don't change according to the page.
This is what I have as the partial that is being rendered...
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用页面参数而不是 id。
@shipments = Shipment.page(params[:page]).per(3)
Use the page parameter and not id.
@shipments = Shipment.page(params[:page]).per(3)