# Will paginate and sorting

**URL:** <https://www.ruby-forum.com/t/will-paginate-and-sorting/156829>\
**Category:** Rails\
**Created:** [January 3, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/will-paginate-and-sorting/156829 "2009-01-03T19:06:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 3, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/will-paginate-and-sorting/156829/1 "2009-01-03T19:06:26Z")

</div>

Hello,  
I have my own functions in the controller and i want to use will  
paginate.  
when i use will paginate then i face the following problems,  
1.I cannot sort the commplete results after search…i can only sort the  
results that are there on a particular page but not the whole set of  
results.

1. Since i am using my own defined functions in the controller clicking  
on the  
next page in will\_paginate takes me to a controller action (i think  
index or show) which in my application has nothing to do with  
searching…so i get an error.  
What do i need to do  
Thank you.

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 3, 2009, 7:47pm UTC](https://www.ruby-forum.com/t/will-paginate-and-sorting/156829/2 "2009-01-03T19:47:45Z")

</div>

On Sat, Jan 3, 2009 at 10:06 AM, Ank Ag  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> on the  
> next page in will\_paginate takes me to a controller action (i think  
> index or show) which in my application has nothing to do with  
> searching…so i get an error.  
> What do i need to do  
> Thank you.

Hi, what does your user defined function do that the conditions has  
doesn’t  
do? In any case, here’s a good Railscast that handles this very nicely:

> **[\#51 will\_paginate - RailsCasts](http://railscasts.com/episodes/51-will-paginate)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 4, 2009, 4:16am UTC](https://www.ruby-forum.com/t/will-paginate-and-sorting/156829/3 "2009-01-04T04:16:09Z")

</div>

Quoting Ank Ag [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hello,  
> I have my own functions in the controller and i want to use will  
> paginate.  
> when i use will paginate then i face the following problems,  
> 1.I cannot sort the commplete results after search…i can only sort the  
> results that are there on a particular page but not the whole set of  
> results.

See [http://mislav.uniqpath.com/static/will\_paginate/doc/](http://mislav.uniqpath.com/static/will_paginate/doc/) and click on  
the  
WillPaginate::Collection link on the left and read the docs on create().

HTH,  
Jeffrey
