I’m new in RoR, and I want to include pagination in my application.
Which is the best way to perform this task? Please suggest me. Is it possible to use will_paginate gem in rails 3.2.3 ?
If yes, in which method I should include:
Post.where(:published => true).paginate(:page => params[:page]).order('id DESC')
Post.page(params[:page]).order('created_at DESC')
Yes, it is possible to use
will_paginategem in rails 3.2.3 applications.And the code will depends on what each action will perform.
The code below usually goes on a
#indexmethod, in yourPostsController.So, in your
posts/index.html.erbview file you can use the following code to display the pagination links: