summaryrefslogtreecommitdiff
path: root/app/controllers/search_controller.rb
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-23 20:46:17 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-23 20:46:17 -0400
commit9003a9099719a771fbbb9d2e8a4bfb093f35929a (patch)
tree83c11934584978d84bf4c5ced57f9fc883e91b60 /app/controllers/search_controller.rb
parent66f225b6aef0946a79abee5e67f74afbf8ea9d1e (diff)
parent9afd5a4f7a86eeaab3fa8a0c25609ac7977e0489 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r--app/controllers/search_controller.rb19
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