X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=app%2Fcontrollers%2Fgame_controller.rb;h=c75ce0765d5dfba998d81e24bca933e296698082;hb=b12881a928516bca02b2bd8ce1bbe9288840c76f;hp=1b5743524e46ec66dabaf6696427d6e85c77690f;hpb=28e07f23e1c75f7442dd87caf34f0f47109bf966;p=cs356-p2-videostore.git diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 1b57435..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) @@ -21,12 +25,7 @@ class GameController < ApplicationController end def create - # A new rentable must be created whenever we create a new game - @rentable = Rentable.new - @rentable.rtype = 'game' - @rentable.save @game = Game.new(params[:game]) - @game.rentable_id = @rentable.id if @game.save flash[:notice] = 'Game was successfully created.' redirect_to :action => 'list' @@ -53,4 +52,14 @@ class GameController < ApplicationController Game.find(params[:id]).destroy redirect_to :action => 'list' end + + 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