will_paginate在rails3中生成转义的html,raw和.html_safe似乎没有帮助

时间:2010-06-21 03:26:40

标签: ruby-on-rails ruby-on-rails-3 will-paginate

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) %>

的Gemfile:

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

1 个答案:

答案 0 :(得分:0)

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

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