# Using will paginate

**URL:** <https://www.ruby-forum.com/t/using-will-paginate/105173>\
**Category:** Rails\
**Created:** [May 26, 2007, 5:26pm UTC](https://www.ruby-forum.com/t/using-will-paginate/105173 "2007-05-26T17:26:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmcervera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Post date:** [May 26, 2007, 5:26pm UTC](https://www.ruby-forum.com/t/using-will-paginate/105173/1 "2007-05-26T17:26:44Z")

</div>

Hello.  
I am trying to use the will\_paginate plugin and I like it very much.

I have read an entry in this forum  
[http://www.ruby-forum.com/topic/109036](http://www.ruby-forum.com/topic/109036), about making will\_paginate an  
acts\_as taggable playing together and  
that make me think it will be easy to paginate on a query moved to the  
model,  
like it was suggested from Jamis B.s in a known article “Skinny  
controller, Fat Mode”.

I have defined a query method in the model

class Thing  
def self.find\_special\_list  
find(:all, :conditions =\> …)  
end  
alias find\_all\_special\_list find\_especial\_list  
end

I pretend paginate with this  
@things = Thing.paginate\_special\_list and I have a strange error saying  
that find\_special\_list is not defined or something like that.

Anybody has tried this?. Is possible to paginate a collection queried  
with a class method?

Thanks

---

<div class="post-metadata">

**Author:** ![jmcervera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Post date:** [May 28, 2007, 1:29pm UTC](https://www.ruby-forum.com/t/using-will-paginate/105173/2 "2007-05-28T13:29:08Z")

</div>

just to be sure:  
alias find\_all\_special\_list find\_especial\_list

should not be  
alias find\_all\_special\_list find\_special\_list

and  
def self.find\_special\_list

is really a class method ?

marcel

On 26 Mai, 17:26, Juanma C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jmcervera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Post date:** [May 29, 2007, 4:54am UTC](https://www.ruby-forum.com/t/using-will-paginate/105173/3 "2007-05-29T04:54:00Z")

</div>

You 're right  
it should be find\_all\_special\_list find\_special\_list  
and I pretend that find\_special\_list be a class method (a custom finder  
method)  
Maybe the alias methods can not be used with class methods, can it?

lanzm wrote:

> just to be sure:  
> alias find\_all\_special\_list find\_especial\_list
> 
> should not be  
> alias find\_all\_special\_list find\_special\_list
> 
> and  
> def self.find\_special\_list
> 
> is really a class method ?
> 
> marcel
> 
> On 26 Mai, 17:26, Juanma C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jmcervera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Post date:** [May 30, 2007, 7:07pm UTC](https://www.ruby-forum.com/t/using-will-paginate/105173/4 "2007-05-30T19:07:54Z")

</div>

Thank you very much Chris

---

<div class="post-metadata">

**Author:** ![jmcervera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Post date:** [June 2, 2007, 10:03am UTC](https://www.ruby-forum.com/t/using-will-paginate/105173/5 "2007-06-02T10:03:46Z")

</div>

Well, I think I go to nowhere with this idea.  
I tried to move the query I am paginating from the controller to the  
model.  
I want to have my controllers as skinny as possible.  
But, obviously I donÂ´t want to move the paginate method to the model,  
nor fight with pages, offsets and limits in the query, only I wan to use  
a finder defined there.

Anythody thinks this is something possible with pagination?  
How?

---

<div class="post-metadata">

**Author:** ![jmcervera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@jmcervera](https://www.ruby-forum.com/u/jmcervera)\
**Post date:** [May 30, 2007, 6:09pm UTC](https://www.ruby-forum.com/t/using-will-paginate/105173/6 "2007-05-30T18:09:53Z")

</div>

On 5/28/07, Juanma C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You 're right  
> it should be find\_all\_special\_list find\_special\_list  
> and I pretend that find\_special\_list be a class method (a custom finder  
> method)  
> Maybe the alias methods can not be used with class methods, can it?

class Whatever \< ActiveRecord::Base  
class \<\< self  
alias\_method :target, :source  
end  
end

or

[http://pastie.caboo.se/66108](http://pastie.caboo.se/66108)

–  
Chris W.  
[http://errfree.com](http://errfree.com) // [http://errtheblog.com](http://errtheblog.com)
