Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kaminari::Cells paginate method not rendering anything

I'm using the Kaminari::Cells gem, and when I use the paginate method in a cell view, nothing shows up. I checked, and the paginate method is just returning "\n".

like image 350
neurodynamic Avatar asked Feb 07 '23 20:02

neurodynamic


1 Answers

I'm not sure why it works, but athlon-krum suggested removing the paginator.render do block of the _paginator.html.erb Kaminari view file, changing it from this:

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

to this:

<%- pagination_class ||= '' %>
<ul class="pagination <%= pagination_class %>">
  <%= paginator.first_page_tag unless current_page.first? %>
  <%= paginator.prev_page_tag unless current_page.first? %>
  <% paginator.each_page do |page| -%>
      <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
          <%= paginator.page_tag page %>
      <% elsif !page.was_truncated? -%>
          <%= paginator.gap_tag %>
      <% end -%>
  <% end -%>
  <%= paginator.next_page_tag unless current_page.last? %>
  <%= paginator.last_page_tag unless current_page.last? %>
</ul>

and that seems to work. Don't forget to prepend paginator. to the Kaminari method calls to make it work (the examples above show this change, but it's easy to miss).

like image 169
neurodynamic Avatar answered Feb 18 '23 13:02

neurodynamic