I was working on a section of my application that uses pagination.  I was running into a problem, though.  When will_paginate creates the pagination link it did not include some of the parameters I am using to keep the state of my application.  I tried adding the parameters onto the end of the will_paginate link like so:

<%= will_paginate @widgets, :param1=>@param1, :param2=>@param2 %>  #not working

That does not work. So I did some searching and found out that you have to include a hash named “params”.  After I added this I was able to get the parameters in my controller.

<%= will_paginate @widgets, :params=>{:param1=>@param1, :param2=>@param2} %>  #Now it works :-)

Tags: ,