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
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Christopher Jones 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? > > endI 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.