Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_nth
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ngô Trung Hưng
venjob_nth
Commits
7f10504a
Commit
7f10504a
authored
Aug 18, 2020
by
Ngô Trung Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update func set language
parent
67ac663b
Pipeline
#950
canceled with stages
in 0 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
app/controllers/apply_job_controller.rb
+1
-1
app/controllers/users_controller.rb
+1
-3
app/models/user.rb
+8
-0
No files found.
app/controllers/apply_job_controller.rb
View file @
7f10504a
...
...
@@ -5,7 +5,7 @@ class ApplyJobController < ApplicationController
before_action
:authenticate_user!
def
index
@jobs
=
current_user
.
applied_jobs
.
order
(
created_at: :desc
).
page
(
params
[
:page
]).
per
(
6
)
@jobs
=
current_user
.
applied_jobs
.
includes
(
:job
).
order
(
created_at: :desc
).
page
(
params
[
:page
]).
per
(
6
)
end
def
apply
...
...
app/controllers/users_controller.rb
View file @
7f10504a
...
...
@@ -10,9 +10,7 @@ class UsersController < ApplicationController
def
my_page
;
end
def
set_lang
if
user_signed_in?
&&
current_user
.
language
!=
params
[
:lang
]
User
.
update
(
current_user
.
id
,
language:
params
[
:lang
])
if
params
[
:lang
]
==
'vi'
||
params
[
:lang
]
==
'en'
end
current_user
.
update_current_language
(
params
[
:lang
])
if
user_signed_in?
redirect_to
'/'
end
end
app/models/user.rb
View file @
7f10504a
...
...
@@ -4,6 +4,7 @@
class
User
<
ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
VALID_LANG_CODES
=
%w[vi en]
.
freeze
mount_uploader
:cv
,
CvUploader
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:validatable
,
:confirmable
...
...
@@ -14,4 +15,11 @@ class User < ApplicationRecord
has_many
:favorites
validates_length_of
:name
,
within:
4
..
200
validates_length_of
:email
,
within:
8
..
200
def
update_current_language
(
new_lang
)
return
if
new_lang
==
language
||
VALID_LANG_CODES
.
exclude?
(
new_lang
)
self
.
language
=
new_lang
save
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment