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

发布于 2024-09-06 08:46:46 字数 1592 浏览 5 评论 0原文

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

will_paginate produces escaped html, what am I missing here. I've verified that will_paginate producted html_save code, I've tried adding will_paginate(@pictures).html_safe as well. Note that page_entries_info works as it should, its just the main helper that is messed up. For the time being I've done the code manually, but for obvious reasons I would prefer to use the proper helper for this.

controller:

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

view:

<% @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'

Output:

<span class="disabled prev_page">&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 &raquo;</a>
2 Displaying pictures 1 - 4 of 6 in total

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳钉梦 2024-09-13 08:46:46

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

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

I've been using newer versions of will_paginate and Rails with no problems.

You could try kaminari, as it's better suited for Rails 3.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文