summaryrefslogtreecommitdiff
path: root/app/controllers/search_controller.rb
blob: d3126233ecab997824b39372c1ed521dcd167133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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