The situation will like this …. …. a user have many posts. But if I loop back all the posts, it will become very slow. So, I may look back the first ten (1-10). When the user click “next”, it will get the (11-20). So, my question is, how can I implement it?? thank you.
<%=h @user.posts.inspect %> <!--It can show all the posts, but I want first ten only-->
Most Rails developers use the will_paginate gem for this and with good reason because it’s really very easy to use: