Skip to content

Customising Pagination

jamesosb edited this page Nov 28, 2012 · 2 revisions

Blogit uses Kaminari for the pagination.

You can generate the views for Kaminari by running rails g kaminari:views default.

This creates 7 partials which you can then customise. You probably want to look closest at _paginator.html.erb.

If you're using something like bootstrap that means adapting the code something like this:

<%= paginator.render do -%>
 <nav class="pagination pagination-centered">
<ul>
 <li><%= first_page_tag unless current_page.first? %></li>
 <li> <%= prev_page_tag unless current_page.first? %></li>
 <% each_page do |page| -%>
  <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
  <li>   <%= page_tag page %></li>
  <% elsif !page.was_truncated? -%>
  <li>   <%= gap_tag %></li>
  <% end -%>
<% end -%>
<li><%= next_page_tag unless current_page.last? %></li>
<li><%= last_page_tag unless current_page.last? %></li>
</ul>
</nav>
<% end -%>
Clone this wiki locally