will_paginate plugin is best solution It can retrieve records for particular page, not whole record set.
@customers = Customer.paginate( :page => :params[:page], :limit => 10 ) Sandip R~ On Wed, Sep 9, 2009 at 11:56 AM, Terry <[email protected]> wrote: > > hey dude. > I think by your requirement, you'd better use the ajax for the pagination. > read all the records from DB in your index action, and latter use ajax > for the pagination(you will not need access your index action again ) > > BTW: will you use cache in your app? if, yes your way is not bad > either. Though every time when you selecting the page, you will access > the index action. but it will not get the records from your DB , it > will get from your cache. > > I prefer the cache one. > > Hope it gives you some help. > > yours, > Terry > > > 2009/9/9 Venkat Eee <[email protected]>: > > > > Hi all, > > > > In my controller > > def index > > @customers = Customer.find(:all) > > @size = @customers.size > > @total_pages = (@customers.size / $PER_PAGE.to_f).ceil > > end > > > > In index.html.erb > > Displays a customer list with pagination(Example: 1,2,3,4,5....) > > > > On each page number click (Example: 1,2,3,4,5...) - the below code in > > index function gets executed. > > > > @customers = Customer.find(:all) > > @size = @customers.size > > @total_pages = (@customers.size / $PER_PAGE.to_f).ceil > > > > This results in performace lack. > > > > So I want to read the db records only once and store it in some > > variable. > > And i will use that variable to display the records for 2,3,4,5 pages. > > > > Please note: I don't want to use any plugins and please help to > > implement.. > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > > > > > > -- Ruby on Rails Developer http://sandip.sosblog.com http://funonrails.wordpress.com www.joshsoftware.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

