diff options
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r-- | app/controllers/search_controller.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index ee61487..d312623 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,2 +1,30 @@ class SearchController < ApplicationController + + def go + stringMade = false; + @games = Game.all + @query = params[:query] + @gametype = params[:game_type] + + if ( @gametype.nil? and (@query.nil? or @query.empty?)) then + return + end + + 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 + end |