2012-01-19 53 views
1

我正在使用Rails 3,ActiveAdmin和Kaminari。Rails 3. 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> 

回答

3

使用页面参数,而不是ID。

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

+0

Doh!谢谢詹姆斯 – leonel

相关问题