我有 will_paginate 插件在应用程序中工作,但是当我对资源进行分页时,它只是将 HTML 作为文本吐出,不提供指向下一页等的链接。
当我手动输入 URL 时,插件正在工作,它只是不会<%= will_paginate @products %>
生成诸如 next 1 2 3 ... last 之类的链接
这是输出
<span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="/products?page=2" rel="next">2</a> <a href="/products?page=2" class="next_page" rel="next">Next &raquo;</a>
控制器:def索引
@products = Product.all.paginate :per_page => 5, :page => params[:page]
@product_categories = ProductCategory.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @products }
end
结尾
看法
<%= will_paginate @products %>
<%= will_paginate %> #for some reasons this works too