X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=app%2Fcontrollers%2Fgame_controller.rb;h=c75ce0765d5dfba998d81e24bca933e296698082;hb=d9ccb8cf52aee119343545cb734e185580daf352;hp=31fe67eecf2e4201685b5fe74bd07d525c603eff;hpb=233a6b122bc4aed44a0babee0797d2dba6da5b06;p=cs356-p2-videostore.git diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 31fe67e..c75ce07 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -1,11 +1,11 @@ class GameController < ApplicationController + layout "admin" # Make sure that the user has logged in before they can take any action before_filter :authorize def index - list - render :action => 'list' + render :action => 'index' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) @@ -53,12 +53,13 @@ class GameController < ApplicationController redirect_to :action => 'list' end - def searchbyname - render :action => 'searchbyname' - end - - def searchresults - query = params[:q] - @games = Game.find(:all, :conditions => ["title like ?", query[0]+"%"]) + def search + if request.post? + @query = params[:q] + @games = Game.find(:all, :conditions => ["title like ?", @query[0]+"%"]) + render :action => 'searchresults' + else + render :action => 'search' + end end end