I have the following code
view (global partial code)
<% if @paging.total_pages > 1 %>
<div class='pagination_container'>
<div class='nav-pagination-new'>
<%= will_paginate @paging, previous_label: h('«'), next_label: h('»'), outer_window: 8 %>
<label class='nav-title go-to-page'>Go to page
<%= text_field_tag params[:page], params[:page], class: 'nav-input form-input-sm', onchange: "if(this.value){window.location='?page='+this.value;}" %> / <%= @paging.total_pages %>
</label>
</div>
<div>
<label class='nav-title' for='show'>Show</label>
<%= select_tag :per_page, options_for_select([25, 50, 100], params[:per_page].to_i), class: 'customSelect nav-input form-input-sm', onchange: "if(this.value){window.location='?per_page='+this.value;}" %>
</div>
</div>
<% end %>
We have a global partial, so we have the following in each view @paging = @order_pages ie orders/index.html.erb and I have the following in the controller.
def index
@order_pages, @orders = SalesOrder.paginate(page: params[:page], per_page: @per_page)
end
However, when loading the page I get the following, undefined method 'total_pages' for nil:NilClass
This is a legacy app, so I'm trying to fix the pagination as is and refactor it later as this is affecting 110 pages.
I have refactored the pagination for it to be more streamlined, so just trying to find a decent solution to get it working on the global partial.