# Named Scopes and Will\_paginate

**URL:** <https://www.ruby-forum.com/t/named-scopes-and-will-paginate/168754>\
**Category:** Rails\
**Created:** [May 25, 2009, 1:31pm UTC](https://www.ruby-forum.com/t/named-scopes-and-will-paginate/168754 "2009-05-25T13:31:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [May 25, 2009, 1:31pm UTC](https://www.ruby-forum.com/t/named-scopes-and-will-paginate/168754/1 "2009-05-25T13:31:16Z")

</div>

I would like to move the following code to a model using named\_scopes.  
I cannot find a good example to show me the way name\_scopes and  
will\_paginate go hand in hand.

@images = Image.paginate :page =\> params[:page],  
:per\_page =\> 10, :order =\> ‘created\_at  
DESC’

Can anybody help me on this?

John

---

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [May 25, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/named-scopes-and-will-paginate/168754/2 "2009-05-25T15:07:31Z")

</div>

Just use Image.named\_scope.paginate instead of Image.paginate.  
Presumably  
the :order will be in the named scope.

Colin

2009/5/25 Hunt J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
