Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#_edition_exists(id) ⇒ Object


53
54
55
# File 'app/controllers/application_controller.rb', line 53

def _edition_exists(id)
	game_exists(Edition, id)
end

#after_sign_in_path_for(resource) ⇒ Object


18
19
20
# File 'app/controllers/application_controller.rb', line 18

def (resource)
	user_game_shelves_path(resource)
end

#deny_accessObject


62
63
64
65
66
# File 'app/controllers/application_controller.rb', line 62

def deny_access
	redirect_to :back, :alert => "Access denied."
	rescue ActionController::RedirectBackError
		redirect_to '/', :alert => "Access denied."
end

#expansion_existsObject


46
47
48
# File 'app/controllers/application_controller.rb', line 46

def expansion_exists
	game_exists(Expansion, params[:id])
end

#fill_platformsObject


22
23
24
25
26
27
28
29
# File 'app/controllers/application_controller.rb', line 22

def fill_platforms
	@platforms = [ ["All", ""] ]
	@platform_hash = { "" => "All", nil => "All" }
	Platform.joins(:edition).group("platforms.id").having("count(editions.id) > ?", 0).order(:priority, :id).each do |p|
		@platforms << [p.display_title, p.id]
		@platform_hash[p.id.to_s] = p.display_title
	end
end

#game_exists(gameClass, id) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/application_controller.rb', line 31

def game_exists(gameClass, id)
	game = gameClass.friendly.find(id)
	if game.present?
		return true
	else
		redirect_to :back, :alert => "#{gameClass.name} not found"
		return false
	end

	rescue ActiveRecord::RecordNotFound
		redirect_to '/', :alert => "#{gameClass.name} not found"
	rescue ActionController::RedirectBackError
		redirect_to '/', :alert => "#{gameClass.name} not found"
end

#game_maker_onlyObject


56
57
58
# File 'app/controllers/application_controller.rb', line 56

def game_maker_only
	deny_access unless current_user.game_maker_or_more?
end

#has_queryObject


68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/application_controller.rb', line 68

def has_query
	if params[:q].present?
		true
	else
		redirect_to :back, :alert => "You have to type a query string"
	end

	rescue ActionController::RedirectBackError
		redirect_to games_path, :alert => "You have to type a query string"
end

#ignore_referral_spamObject


10
11
12
13
14
15
16
# File 'app/controllers/application_controller.rb', line 10

def ignore_referral_spam
	if(request.referrer)
		if ReferralSpamControl.evaluate_referrer(request.referrer)
			render :nothing => true, :status => 400
		end
	end
end

#reviewer_onlyObject


59
60
61
# File 'app/controllers/application_controller.rb', line 59

def reviewer_only
	deny_access unless current_user.admin?
end

#work_existsObject


50
51
52
# File 'app/controllers/application_controller.rb', line 50

def work_exists
	game_exists(Work, params[:id])
end

#xhr_onlyObject


78
79
80
81
82
# File 'app/controllers/application_controller.rb', line 78

def xhr_only
	if not request.xhr?
		render :nothing => true, :status => 400
	end
end