X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=app%2Fcontrollers%2Fgame_controller.rb;h=c75ce0765d5dfba998d81e24bca933e296698082;hb=d9ccb8cf52aee119343545cb734e185580daf352;hp=39f5485d787ddfed3ca597539c4012c81168bdd7;hpb=0dccca2d3c0e9d5e6eaa1c1ebee3670654fd8c43;p=cs356-p2-videostore.git diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 39f5485..c75ce07 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -1,7 +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) @@ -49,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 = ?", query]) + 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