Kaminari :: The paginate method of objects does not render anything

I use the Kaminari :: Cells stone, and when I use the paginate method as a cell, nothing appears. I checked and the paginate method just returns "\ n".

+4
source share
2 answers

I'm not sure why it works, but athlon-krum suggested deleting the Kaminari paginator.render doview file block by _paginator.html.erbchanging it:

<%= 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 %>

:

<%- 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>

, , . paginator. Kaminari, ( , ).

+6

, , kaminari #paginate @template self , . Rails @template , , ActionView:: Base. @template . kaminari, ActionView::OutputBuffer. , #render #render -, #render .

- :

Kaminari::Helpers::Paginator.class_eval do
  def render(&block)
    instance_eval(&block) if @options[:total_pages] > 1
    # @output_buffer
  end
end
+2

Source: https://habr.com/ru/post/1627208/


All Articles