diff options
author | tkimia <tkimia@purdue.edu> | 2014-04-23 20:26:37 -0400 |
---|---|---|
committer | tkimia <tkimia@purdue.edu> | 2014-04-23 20:26:37 -0400 |
commit | cba4c47e7cca06434742fc5fd282c40973c546d1 (patch) | |
tree | f16d4e7892777836d2c22a00b1194d255adab95e /app/controllers | |
parent | d0a0f806a4bb8072c532ea7b35ad8b7643ac8645 (diff) |
started with advanced search
Diffstat (limited to 'app/controllers')
-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 |