Connecting Tech Pros Worldwide Forums | Help | Site Map

Pagination in Ruby on Rails

Newbie
 
Join Date: Oct 2007
Posts: 19
#1: Jul 7 '08
Hello,
I have generated ruby reports for my application.For html display of report,i have to use next,previous links for navigation.I need to have 10 records per page.And when click on next link,i should be able to retrieve the next 10 records.For retreiving records, i have used find_by_sql query.By this i can limit the records,but displaying other records in next page,i am not able to do.
How can i do this.Please help me.Its urgent.

Thanks in advance

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Jul 7 '08

re: Pagination in Ruby on Rails


Take a look at the will_paginate gem/plugin.
Expert
 
Join Date: May 2007
Posts: 213
#3: Jul 8 '08

re: Pagination in Ruby on Rails


Rails did have built in pagination, which would work, but it was deprecated in Rails 2.0. Otherwise, you will probably want to use the will_paginate plugin mentioned above or write pagination by hand using variables to track your current location in the records. Might just depend how complicated or elegant you want it.
Reply