在rails 3上使用will_paginate对表进行排序

imo*_*mon 5 sorting ajax pagination ruby-on-rails-3

我想知道怎样才能用分页(will_paginate)对表格列进行排序,我已经有了一个分页但是我不知道如何对表格进行排序,即使它有一个分页,我需要的东西是均匀的有一个分页,当你对你想要的列进行排序时,它会对你想要排序的相应列进行排序,就像它应该从第1页升序或降序到其他页面直到最后,即使你在页面中,例如4 ,当我对ID进行排序时,例如从降序到升序(100 - > 1135),不仅在该页面中,而且它将对所有列出的数据进行排序......

我应该在控制器或助手以及我的表格中添加什么?

谢谢,希望有人会回答这个,

index.html.erb

<table class="patchtable tablesorter"> <thead>
<th>ID</th>
<th>Summary</th>
<th>Module</th>
<th>Target</th>
<th>Category</th>
<th>Priority</th>
<th>Status</th>
<th>Assigned</th></tr>
Run Code Online (Sandbox Code Playgroud)

<%= will_paginate @patches, :url => '/admin/patches', :align => "center", :params => {:controller => '/admin/patches', :action => nil, :order => @filter.filter_hash} %> <%= page_entries_info @patches, :entry_name => 'item' %>
Run Code Online (Sandbox Code Playgroud)

我的控制器:

@patches = Admin::Patch.all(:conditions => filter_hash).paginate(:per_page => Admin::Patch.per_page, :page => params[:page])
Run Code Online (Sandbox Code Playgroud)

我该怎么办,添加或其他工作正常,请回复..

小智 7

请参阅此链接http://railscasts.com/episodes/228-sortable-table-columns.你会得到你想要的一切.