will_paginate を使用した場合、
生成されるページングのリンクのクエリーストリングが
最初にリクエストしたものと異なってしまう場合がある。
理由は、url_forを使ってhashを展開してるからで
クエリーストリングの順番は保証されない。
なんてこった(大した問題じゃないが)。
例
request時
http://localhost:3000/test?a=1&b=2
生成されるリンク
http://localhost:3000/test?b=2&a=1&page=2
http://localhost:3000/test?b=2&a=1&page=3
みたいなことになっちゃう可能性がある。
ということで
renderer オプションを使用し
カスタムクラスの中で変更してみた。
強引だけど、一応実現できた。
#view <%= will_paginate @models, { :renderer => 'CustomLinkRenderer', :request_uri => @_request.request_uri }%> #environment.rb class CustomLinkRenderer < WillPaginate::LinkRenderer def page_link(page, text, attributes = {}) #@template.link_to text, url_for(page), attributes @template.link_to text, custom_page_link(page) , attributes end def custom_page_link(page) uri = (@options[:request_uri] or "") if uri.match(/page=\d+$/) uri.sub(/page=\d+$/, "page=#{page}") else if uri.match(/\?/).nil? uri << "?page=#{page}" else uri << "&page=#{page}" end end end end