Class: Com::CommonController
Constant Summary
RailsCom::Application::LOCALE_MAP
Instance Method Summary
collapse
#current_title, #default_form_params, #default_params, #json_format?, #set_country, #set_flash, #set_locale, #set_timezone, #set_variant
Instance Method Details
#cache_list ⇒ Object
17
18
19
|
# File 'app/controllers/com/common_controller.rb', line 17
def cache_list
render json: CacheList.all.as_json(only: [:path, :key], methods: [:etag])
end
|
#cancel ⇒ Object
14
15
|
# File 'app/controllers/com/common_controller.rb', line 14
def cancel
end
|
#deploy ⇒ Object
commit message end with ‘@deploy’
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/com/common_controller.rb', line 39
def deploy
require 'deploy'
digest = request.['X-Hub-Signature'].to_s
digest.sub!('sha1=', '')
payload = JSON.parse(params[:payload])
if digest == Deploy.github_hmac(request.body.read) && payload.dig('head_commit', 'message').to_s.end_with?('@deploy')
result = Deploy.exec_cmds Rails.env.to_s
else
result = ''
logger.debug "==========> Deploy failed"
end
render plain: result
end
|
#enum_list ⇒ Object
21
22
23
24
25
|
# File 'app/controllers/com/common_controller.rb', line 21
def enum_list
r = I18n.backend.translations[I18n.locale][:activerecord][:enum]
render json: { locale: I18n.locale, values: r }
end
|
#info ⇒ Object
7
8
9
10
11
12
|
# File 'app/controllers/com/common_controller.rb', line 7
def info
q_params = {}
q_params.merge! params.permit(:platform)
@infos = Info.default_where(q_params)
end
|
#qrcode ⇒ Object
27
28
29
30
31
32
|
# File 'app/controllers/com/common_controller.rb', line 27
def qrcode
options = qrcode_params.to_h.symbolize_keys
buffer = QrcodeHelper.code_png(params[:url], **options)
send_data buffer, filename: 'cert_file.png', disposition: 'inline', type: 'image/png'
end
|
#test_raise ⇒ Object
34
35
36
|
# File 'app/controllers/com/common_controller.rb', line 34
def test_raise
raise 'error from test raise'
end
|