我正在尝试将 will_paginate 用于要显示的项目列表。有一个带有下拉选项的表单,可以按状态获取对象。这是我的控制器
def list
@person = Person.find_by_id(session[:person_id])
params[:status] = params[:redirect_status] if params.has_key?('redirect_status')
@statuses = Peptide.statuses
@status = 'Not Ordered'
@status = params[:status] if params[:status] != nil || params[:status] == ''
@peptides = Peptide.find(:all, :conditions => ['status = ?', @status]).paginate(:per_page => 30, :page => params[:page])
if Peptide.count.zero?
flash[:notice] = "There are not any peptides entered"
redirect_to :action => 'new'
end#if zero
end
这是在视图中
<form action="/peptide/create_spreadsheet_of_not_ordered" enctype="multipart/form-data" method="post">
<table class="sortable" cellpading="5" cellspacing="2" width="100">
<tr class= "header-line">
<th>SS</th>
<th>Status</th>
<th>Peptide</th>
<th>Gene</th>
<th>Submitter</th>
<th>Created</th>
<th>Updated</th>
<th>Sequence</th>
<th>Modification</th>
<th>Vendor</th>
</tr>
<% for @peptide in @peptides.reverse %>
<tr valign = "top" class= "<%= cycle('color_one', 'color_two') %>">
<!--an error here during development likely indicates that the people table has not be repopulated or
that no submitter primer is present for a primer-->
<td sorttable_customkey = 0 > <%=check_box_tag "box[]", @peptide.id %>
<td><%= @peptide.status%></td>
<td class><%= link_to @peptide.name, :action => :report, :id => @peptide.id %></td>
<td><%= gene_links(@peptide.genes) rescue 'Error'%></td>
<td><%= @peptide.submitter.name rescue "" %></td>
<td <%= sorttable_customkey_from_date(@peptide.created_at)%> >
<%= @peptide.created_at.strftime("%b %d %Y") rescue "Unknown"%>
</td>
<td <%= sorttable_customkey_from_date(@peptide.updated_at)%> >
<%= @peptide.updated_at.strftime("%b %d %Y") rescue "Unknown"%>
</td>
<td><%= @peptide.sequence%></td>
<td><%= @peptide.modifications%></td>
<td><%= @peptide.vendor%></td>
<%= buttons() %>
</tr>
<%end%>
<%= will_paginate @peptides %>
</table>
<br>
<%= submit_tag "Create Spreadsheet"%>
默认列表按排序状态分组。
但是,当我选择任何其他状态并提交表单时,分页链接会将我带回默认状态。请帮我解决这个问题。谢谢