我正在尝试按字母顺序分页 - 所以我的指南将按字母顺序列出(并分组),顶部的分页将是按字母顺序排列的列表。到目前为止,我有:
指南控制器.rb
def index
if params[:search].present?
@search = Sunspot.search(Guideline) do
fulltext params[:search]
end
@guidelines = @search.results
else
@guidelines = Guideline.order(:title).page(params[:page]).per(5).to_a.group_by{|u|u.title[0].upcase}
end
index.html 视图
<%= paginate @guidelines %>
<% @guidelines.keys.sort.each do |starting_letter| %>
<h3>
<%= link_to starting_letter, {:action => :browse, :controller =>:index, :letter => starting_letter } %>
</h3>
<% @guidelines[starting_letter].each do |guideline| %>
然后是视图的其余部分
这给了我错误
ActionView::Template::Error (undefined method `current_page' for #<Hash:0x007fd974700148>):
1: <%= paginate @guidelines %>
2:
3: <div class="page-header">
4: <% if @search %>
app/views/guidelines/index.html.erb:1:in `_app_views_guidelines_index_html_erb___4442223584034894893_70285969096020'
app/controllers/guidelines_controller.rb:25:in `index'
我离解决方案很近吗?谢谢