Paginate with multiple criteria

I have pagination on my users table at the moment which works fine as I
only have one search feature for users.

But I now wish to add pagination to my games table but not sure how to
implement it as I have 5 search features for games. I was wondering how
I would go about adding the pagination to the following controller
method.

def index
@games = Game.gamsearch(params[:gamsearch])
@games = Game.consearch(params[:consearch]) if
params[:consearch].present?
@games = Game.gensearch(params[:gensearch]) if
params[:gensearch].present?
@games = Game.where(“game_name LIKE ?”, “#{params[:game_name]}%”) if
params[:game_name].present?
@games = Game.where(“console = ?”, params[:console]) if
params[:console].present?

end

Christopher J. wrote in post #1054663:

I have pagination on my users table at the moment which works fine as I
only have one search feature for users.

But I now wish to add pagination to my games table but not sure how to
implement it as I have 5 search features for games. I was wondering how
I would go about adding the pagination to the following controller
method.

def index
@games = Game.gamsearch(params[:gamsearch])
@games = Game.consearch(params[:consearch]) if
params[:consearch].present?
@games = Game.gensearch(params[:gensearch]) if
params[:gensearch].present?
@games = Game.where(“game_name LIKE ?”, “#{params[:game_name]}%”) if
params[:game_name].present?
@games = Game.where(“console = ?”, params[:console]) if
params[:console].present?

end

I would take apart where clause and execution part.

where = ‘whatever comes here’ if params[:consearch].present?
where = ‘something else’ if params[:gensearch].present?
etc …

@games = Game.where(where).page(params[:page]) …

by
TheR