Rails List plus paging feature

Source: Internet
Author: User

The default list for rails is to fetch all the data, and if the amount of data is large, there is definitely a problem with this approach:

First, it causes memory to go out;

Second, the page will be very long;

Third, loading is also slower.

This time, paging needs to come, always can not write their own pages, it is too troublesome.

Github.com search, oh buy karma, incredibly already have this gem package, decisive to use.

The usage is simple, just need to introduce "Kaminari" in Gemfile, the code is as follows:

Gem ' Kaminari '


Use the following:

Controller: @users = User.order (: name). Page params[:p age]view: <%= paginate @users%>

Specifically, you can view the description of this gem package at the following address:

Https://github.com/amatsuda/kaminari

Rails List plus paging feature

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.