Rails3: How to pass param into custom will_paginate renderer?

我们两清 提交于 2019-12-03 11:13:49

View:

<%= will_paginate @user_friends, :renderer => 'FriendsRenderer',
                         :remote => true,
                         :link_path => friends_widget_user_path(@user) %>

class FriendsRenderer < WillPaginate::LinkRenderer
  def prepare(collection, options, template)
    @link_path = options.delete(:link_path)
    super
  end

protected
  def link(page, text, attributes = {})
    # Here you can use @link_path   
  end
end

Note that this works for the will-paginate version: 2.3.6

will_paginate lets you pass in :params for the links:

will_paginate(@user_friends, :params => { :user_id => 95 })
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!