Nicky Feller Nicky Feller - 10 months ago 107
Ruby Question

Undefined Method Paginate for Searchkick Results

undefined method `paginate' for

Unable to Paginate when using searchkick

if params[:search].present?
@courses =[:search]).paginate(page: params[:page], per_page: 3)
@courses = Course.paginate(page: params[:page], per_page: 3)

When the conditional skips to else. it can render and paginate no problem. But when it is subject to search it refuses to paginate. It seems to be due to the Searchkick gem, this problem does not arise when using regular dumb search.

Answer Source

You have to pass pagination params as #search parameters:

@courses =[:search], page: params[:page], per_page: 3)