will_paginate problem

Sometimes, a search has to be coded in an application and if you are using rails, probably you’ll use will_paginate. It is a good piece of software, easy to install and easy to use but, if it’s not used correctly, problems may appear.

I use it using a form_for rails’s tag and four search criteria in it. After coding it, I added will_paginate and after doing my first search, I paginated to the second page…it came empty. After googling a little, I noticed that I was sending info using POST method and will_paginate needs GET method to work properly, so the only thing needed was:

:html => { :method => :get}

and it worked perfectly, passing parameters to the next pagination.

Hope this helps, it’s something silly but sometimes silly things made people go into the dark side of coding ;-)

M.

 

Leave a comment