-
Notifications
You must be signed in to change notification settings - Fork 4
Pagination
tonyfoti edited this page May 9, 2014
·
2 revisions
This is how to use pagination in rails where a gem just do it:
In the Gemfile add this line :
gem 'kaminari'
Then run bundle install
Next: In the controller of what you want to include pagination with, for example if the resulted items "@items" are what you want to paginate on; it will be as follows:
@items = @items.page(params[:page]).per(5)
where "5" is the amount of(items) you want to show per page (choose what you want).
Now in your view page, add this line :
<%= paginate @items %>
That's it.
You can watch the tutorial where I got it : http://railscasts.com/episodes/254-pagination-with-kaminari