views:

90

answers:

2

I want to do paging of lists of data with ruby on rails. Basically, I want to show only 20 records at a time, with next and back buttons. It would be nice, but not required, to show links for the page numbers.

Something like this would be nice:

<< Previous 1 2 3 4 5 ... Next >>

Is there a built in way to do this in ruby on rails (or something I can add) so I don't have to write this myself?

+3  A: 

will_paginate or similar would be a good start.

CrazyCoder
+1  A: 

There is a plugin will_paginate that can be used to do pagination seamlessly in RoR. Find following links. They might be of some help.

http://nasir.wordpress.com/2007/10/31/pagination-in-ruby-on-rails-using-will%5Fpaginate-plugin/

http://wiki.github.com/mislav/will%5Fpaginate

http://wiki.github.com/mislav/will%5Fpaginate/simple-search

http://blog.railsspace.com/past/2008/1/31/railsspace%5Fwill%5Fpaginate/

Also I am sure that following railscast by Ryan Bates is going to be an excellent source of understanding. All rails casts are really good and give you deep understanding of basics. http://railscasts.com/episodes/51-will-paginate

Priyank
That was easy, this is great.
NotDan
am glad, I could help. Cheers
Priyank