Raphael Bauduin
2005-Mar-24 19:40 UTC
pagination_links keeping current url''s parameters (patch)
Hi, I''ve modified url_rewriter.rb following advices from Nicholas Seckar to allow a option :overwrite_params, that let you reuse the parameters of the current url for generating a new one, and only overwrite those you need to. For example: link_to "page 2" , :overwrite_params => { :page => "2" } will keep all parameters in the current url, only overwriting the page parameter. If hte current url is http://localhost/public/search?name=zilla&page=1 the generated link will have as href http://localhost/public/search?name=zilla&page=2 Or if we are at http://localhost/public/search?name=zilla&page=1&encoding=1&items_per_page=20&lang=fr we''ll get a link http://localhost/public/search?name=zilla&page=1&encoding=1&items_per_page=20&lang=fr&page=2 I''ve patched the pagination_links code to use this parameter too. This keep all parameters from the current url (except the page number to display for my_paginator), you can just do <%= pagination_links my_paginator, :overwrite_params => {} %> For those interested, see tickets #921 and #922 . These tickets have patches against actionpack 1.6.0. I don''t have the time to check out a current svn version, add all needed tests, etc So feel free to correct it, enhance it, patch it, etc. I just hope the features added by these patched will get in, I don'' t mind if it''s another implementation ;-) Raph