Reputation: 718
I heard that Pagination is included automatically for all controllers? How can it be implemented?
Upvotes: 1
Views: 3891
Reputation: 718
The more recent kaminari gem can be used in Rails 3. You can refer https://github.com/amatsuda/kaminari
it is very simple to use.
Put this line in your Gemfile:
gem 'kaminari'
Then do bundle install
Typically, your controller code will look like this:
@users = User.order(:name).page params[:page]
On the views Just call the paginate helper:
<%= paginate @users %>
Now you can see the paginated result..
Upvotes: 3
Reputation: 25994
As Don Roby said, there are several pagination gems and will_paginate and Kaminari are 2 popular ones. You can find some nice tutorial on pagination (incl. using these 2 gems) here : http://railscasts.com/episodes?utf8=%E2%9C%93&search=pagination
Upvotes: 1
Reputation: 41127
As far as I know, there's nothing included automatically. I believe there was built-in pagination in much earlier versions of Rails.
There are (at least) two gems that can be installed to do pagination. The will_paginate gem has been around for years and can be used in Rails 2 or 3. The more recent kaminari gem can be used in Rails 3.
Upvotes: 4