X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=app%2Fcontrollers%2Fgame_controller.rb;h=c75ce0765d5dfba998d81e24bca933e296698082;hb=b12881a928516bca02b2bd8ce1bbe9288840c76f;hp=50f6a95bc37a5d5f44f8f30e7eab17697534d5c5;hpb=7f26973835fc8deef03d25d751e92e4c633ae464;p=cs356-p2-videostore.git diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 50f6a95..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,11 +25,7 @@ class GameController < ApplicationController end def create - # A new rentable must be created whenever we create a new game - @rentable = Rentable.new - @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' @@ -52,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