FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
tip4commit/app/controllers/application_controller.rb at master · tip4commit/tip4commit · GitHub
tip4commit
tip4commit
Repository navigation
Code
Issues
54
(54)
Pull requests
13
(13)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
tip4commit
/
app
/
controllers
/
application_controller.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
47 lines (35 loc) · 1.25 KB
Breadcrumbs
tip4commit
/
app
/
controllers
/
application_controller.rb
Copy path
File metadata and controls
47 lines (35 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true
class
ApplicationController
<
ActionController
::
Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
with
:
:exception
rescue_from
CanCan
::
AccessDenied
do
|
_exception
|
redirect_to
root_path
,
alert
:
I18n
.
t
(
'errors.access_denied'
)
end
before_action
:load_locale
private
def
load_locale
locale
=
locale_from_params
||
session
[
:locale
]
||
locale_from_http_accept_language
I18n
.
locale
=
session
[
:locale
]
=
locale
redirect_back
(
fallback_location
:
root_path
)
if
params
[
:locale
]
.
present?
end
def
locale_from_params
return
unless
params
[
:locale
]
return
unless
::
Rails
.
application
.
config
.
available_locales
.
include?
(
params
[
:locale
]
)
params
[
:locale
]
.
to_sym
end
def
locale_from_http_accept_language
http_accept_language
.
compatible_language_from
(
::
Rails
.
application
.
config
.
available_locales
)
&.
to_sym
end
def
pretty_project_path?
params
[
:service
]
.
present?
&&
params
[
:repo
]
.
present?
end
def
project_not_found
flash
[
:error
]
=
I18n
.
t
(
'errors.project_not_found'
)
redirect_to
(
projects_path
)
end
def
user_not_found
flash
[
:error
]
=
I18n
.
t
(
'errors.user_not_found'
)
redirect_to
(
users_path
)
end
end
Back
|
FazBrowse Home
|
New Git URL