Class: AdvertisementController
Overview
Necessary due to rmagick noinspection RubyResolve, DuplicatedCode, RubyArgCount
Instance Method Summary
collapse
#dashboard, #keyboard_tools, #upload
Instance Method Details
#codidact ⇒ Object
13
14
15
|
# File 'app/controllers/advertisement_controller.rb', line 13
def codidact
send_resp helpers.codidact_ad
end
|
17
18
19
|
# File 'app/controllers/advertisement_controller.rb', line 17
def
send_resp helpers.
end
|
#index ⇒ Object
9
10
11
|
# File 'app/controllers/advertisement_controller.rb', line 9
def index
render layout: 'without_sidebar'
end
|
#promoted_post ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'app/controllers/advertisement_controller.rb', line 72
def promoted_post
promoted = helpers.promoted_posts
if promoted.empty?
return
end
@post = Post.unscoped.find(promoted.keys.sample)
if @post.article?
send_resp helpers.article_ad(@post)
else
send_resp helpers.question_ad(@post)
end
end
|
#random_question ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'app/controllers/advertisement_controller.rb', line 55
def random_question
@post = Rails.cache.fetch 'ca_random_hot_post', expires_in: 5.minutes do
select_random_post
end
if @post.nil?
return
end
if @post.question?
send_resp helpers.question_ad(@post)
elsif @post.article?
send_resp helpers.article_ad(@post)
else
not_found
end
end
|
#specific_category ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/advertisement_controller.rb', line 36
def specific_category
@category = Category.unscoped.find(params[:id])
@post = Rails.cache.fetch "ca_random_category_post/#{params[:id]}",
expires_in: 5.minutes do
select_random_post(@category)
end
if @post.nil?
not_found
elsif @post.question?
send_resp helpers.question_ad(@post)
elsif @post.article?
send_resp helpers.article_ad(@post)
else
not_found
false
end
end
|
#specific_question ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/advertisement_controller.rb', line 21
def specific_question
@post = Post.unscoped.find(params[:id])
if @post.nil?
not_found
elsif @post.question?
send_resp helpers.question_ad(@post)
elsif @post.article?
send_resp helpers.article_ad(@post)
else
not_found
false
end
end
|