Using kaminari with ransack_memory

So for everybody that ever wanted to combine kaminari and ransack_memory and ran into the problem that you could page forward but not backward… changing params_on_first_page in the kaminari_config.rb initializer file did the trick for me. What that does is always use a page parameter. Usually kaminari does not add a page parameter if the target page is the first page in the series. However that wreaks havoc on ransack_memory.

Don’t run the kaminari paging on Post … that just ignores the ransack results and creates a new collection. Run paging on the @post collection.

def index
    @search =[:q])
    @post = @search.result(distinct: true)

    @post = @post.order('created_at DESC').page(params[:page]).per(12)