I'm trying to use will_paginate in conjunction with filterrific. But I'm getting the following error:
undefined method `total_pages' for # Array:0x007f9f6b4a3320>
My controller action:
def index
@filterrific = initialize_filterrific(
current_user.assessments,
params[:filterrific],
:select_options => {
sorted_by: Assessment.options_for_sorted_by },
:persistence_id => false,
) or return
@assessments = @filterrific.find.page(params[:page]).paginate(page: params[:page], per_page: 10).sort_by &:created_at
@assessments.reverse!
end
View:
<%= render(
partial: 'list',
locals: { assessments: @assessments }
) %>
</div>
Partial:
<div id="filterrific_results">
<% @assessments.each do |assessment| %>
....
<% end %>
</div>
<%= will_paginate assessments %>
Where am I going wrong?
Avoid calling sort_by over paginated collection. Add scope to Assessments and specify the scope for filterrific.