Reputation: 829
I want to realize some kind of lazy loading in my rails app. That means I have a query result of about 50 000 lines. I want them to be shown on 50 pages with 100 lines each. I can't load all the data before because it makes my browser crashing down.
So how do I just load a part of my data at a time? Does anyone can tell me some keywords that I can google?!
Thanks in advance!
Upvotes: 0
Views: 1094
Reputation: 1889
Try the will_paginate gem for this functionality: https://github.com/mislav/will_paginate
It allows you to do things like @posts = Post.order('created_at DESC').paginate(:page => params[:page])
in the controller and <%= will_paginate @posts %>
in the view.
Upvotes: 2