Last active
September 7, 2018 15:23
-
-
Save pjbelo/7f7dc0619ff12600da9b064831fb6929 to your computer and use it in GitHub Desktop.
Using Pagy gem with Rails and Bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Include in gemfile: | |
gem 'pagy' | |
for global access, include in application_controller.rb: | |
include Pagy::Backend | |
and in application_helper.rb: | |
include Pagy::Frontend | |
In controller (eg. BlogPosts), where items define number of items per page: | |
@pagy, @blog_posts = pagy(BlogPost.all, items: 20) | |
In the View render the navigation links: | |
<%= pagy_nav_bootstrap(@pagy).html_safe %> | |
or | |
<%== pagy_nav_bootstrap(@pagy) %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment