Reputation: 3899
undefined method `paginate' for
Unable to Paginate when using searchkick
if params[:search].present?
@courses = Course.search(params[:search]).paginate(page: params[:page], per_page: 3)
else
@courses = Course.paginate(page: params[:page], per_page: 3)
end
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.
Upvotes: 2
Views: 1288
Reputation: 7034
You have to pass pagination params as #search
parameters:
@courses = Course.search(params[:search], page: params[:page], per_page: 3)
https://github.com/ankane/searchkick#pagination
Upvotes: 2