Categories
Development

undefined method `total_pages’ for nil:NilClass

I have this error when run my pagination code:

undefined method `total_pages' for nil:NilClass

I cant understand, maybe you can help me?

products_controller.rb

@products = Product.order(:nome).page params[:page]

página:

<ul class="product-evaluation-rating">
    <% avaliacao.questionario_respostas.approved.rated_questions.each do |answer| %>
    <li class="product-evaluation-rating-item">
    <%= answer.questionario_pergunta.custom_question %>
    <%= content_tag :p, class: (answer.questionario_pergunta.custom_question == 'recomendaria' ? 'strong' : nil) do %>
    <%= answer.custom_answer %>
    <% end %>
    </li>
    <% end%>
    </ul>
    <%= paginate @products %>

kaminari_config.rb:
    # frozen_string_literal: true
    Kaminari.configure do |config| 
    # config.default_per_page = 25
    # config.max_per_page = nil
    # config.window = 4
    # config.outer_window = 0
    # config.left = 0
    # config.right = 0
    # config.page_method_name = :page
    # config.param_name = :page
    # config.params_on_first_page = false
    end

Leave a Reply

Your email address will not be published. Required fields are marked *