Change number of elements per page with <%= will_paginate %>
Asked Answered
C

2

9

I'm using the will_paginate gem. The default is 30 elements per page. How do I customize this?

Christean answered 23/3, 2011 at 0:29 Comment(0)
K
11

If your controller is called User, you can do something like this in your controller: @users = User.paginate :page => params[:page], :per_page => 10, :order => 'name ASC' This will show 10 results per page.

In your view: <%= will_paginate @users %>

Kumler answered 23/3, 2011 at 0:36 Comment(0)
M
4

See the per_page option here:

https://github.com/mislav/will_paginate/wiki

It will allow you to change the number displayed per page, for anytime that model is paginated.

For a controller/action specific approach see Raunak's answer.

Machicolate answered 23/3, 2011 at 0:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.