diff options
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r-- | app/controllers/search_controller.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 51aee9e..d312623 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,13 +1,28 @@ class SearchController < ApplicationController def go + stringMade = false; + @games = Game.all @query = params[:query] + @gametype = params[:game_type] - if (@query.nil?) then + if ( @gametype.nil? and (@query.nil? or @query.empty?)) then return end - @tournaments = Tournament.where("name LIKE '%#{@query}%'") + qstring = "" + if (!@query.empty?) + qstring += "name LIKE '%#{@query}%'" + stringMade = true + end + if (!@gametype.nil? and !@gametype.empty?) + if (stringMade) + qstring += " AND " + end + qstring += "game_id=#{@gametype}" + end + + @tournaments = Tournament.where(qstring) @players = User.where("name LIKE '%#{@query}%'") end |