2

will_paginate 产生转义的 html,我在这里缺少什么。我已经验证 will_paginate 产生了 html_save 代码,我也尝试添加 will_paginate(@pictures).html_safe 。请注意, page_entries_info 可以正常工作,它只是搞砸的主要助手。目前我已经手动完成了代码,但出于显而易见的原因,我更愿意为此使用适当的帮助程序。

控制器:

class PicturesController < ApplicationController
  # GET /pictures
  # GET /pictures.xml
  def index
    @pictures = Picture.recent.paginate(:page => params[:page], :per_page => 4)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @pictures }
    end
  end
end

看法:

<% @pictures.each_with_index do |picture, i| %>
  <%= link_to(picture_image_tag(picture, "small"), picture, :class => "picture grid_2 " + nine_sixty_alpha_omega(i, 4)) %>
<% end %>
<div class="clear"></div>

<%=raw will_paginate(@pictures) %>
<%= @pictures.total_pages %>
<%=raw  page_entries_info(@pictures) %>

宝石文件:

source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
gem "mongoid", "2.0.0.beta4"
gem "bson_ext", "0.20.1"
gem 'will_paginate', '3.0.pre', '>= 3.0.pre'
#gem 'agnostic-will_paginate'#, :require => 'will_paginate' 
gem 'mongo'

输出:

<span class="disabled prev_page">&amp;laquo; Previous</span> <span class="current">1</span> <a href="/pictures?page=2" rel="next">2</a> <a href="/pictures?page=2" class="next_page" rel="next">Next &amp;raquo;</a>
2 Displaying pictures 1 - 4 of 6 in total
4

1 回答 1

0

我一直在使用较新版本的 will_paginate 和 Rails,没有任何问题。

你可以试试 kaminari,因为它更适合 Rails 3。

于 2011-02-24T05:31:21.773 回答