开发者

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

开发者 https://www.devze.com 2023-02-18 07:54 出处:网络
I\'m us开发者_如何学编程ing the \'will_paginate\' gem. The default is 30 elements per page. How do I customize this?If your controller is called User, you can do something like this in your controller

I'm us开发者_如何学编程ing the 'will_paginate' gem. The default is 30 elements per page. How do I customize this?


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 %>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消