How to customize the will_paginate link base?

蓝咒 提交于 2019-12-03 09:08:49

You will probably have to write your own LinkRenderer. See this blog post, and the code for LinkRenderer.

Briefly:

in environment.rb you need something like this:

WillPaginate::ViewHelpers.pagination_options[:renderer] = 'MyLinkRenderer'

in application_helper.rb

class MyLinkRenderer < WillPaginate::LinkRenderer
  def page_link(page, text, attributes = {})
    url = url_for(page) # you should find a better way to do this...
    url.sub!('posts','contents')
    @template.link_to text, url, attributes
  end
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!