Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xuan Trung Le
venjob
Commits
a3c73032
Commit
a3c73032
authored
Oct 09, 2017
by
Xuan Trung Le
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update country setting for city
parent
f7c44114
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
+12
-1
app/models/city.rb
+9
-0
app/models/job.rb
+3
-1
No files found.
app/models/city.rb
View file @
a3c73032
...
@@ -2,4 +2,13 @@ class City < ApplicationRecord
...
@@ -2,4 +2,13 @@ class City < ApplicationRecord
belongs_to
:country
,
optional:
true
belongs_to
:country
,
optional:
true
has_and_belongs_to_many
:companies
has_and_belongs_to_many
:companies
has_and_belongs_to_many
:jobs
has_and_belongs_to_many
:jobs
def
self
.
list
[
'AN GIANG'
,
'BÀ RỊA - VŨNG TÀU'
,
'BẮC GIANG'
,
'BẮC KẠN'
,
'BẠC LIÊU'
,
'BẮC NINH'
,
'BẾN TRE'
,
'BÌNH ĐỊNH'
,
'BÌNH DƯƠNG'
,
'BÌNH PHƯỚC'
,
'BÌNH THUẬN'
,
'CÀ MAU'
,
'CAO BẰNG'
,
'DAK LAK'
,
'DAK NÔNG'
,
'ĐIỆN BIÊN'
,
'ĐỒNG NAI'
,
'ĐỒNG THÁP'
,
'GIA LAI'
,
'HÀ GIANG'
,
'HÀ NAM'
,
'HÀ TĨNH'
,
'HẢI DƯƠNG'
,
'HẬU GIANG'
,
'HÒA BÌNH'
,
'HƯNG YÊN'
,
'KHÁNH HÒA'
,
'KIÊN GIANG'
,
'KON TUM'
,
'LAI CHÂU'
,
'LÂM ĐỒNG'
,
'LẠNG SƠN'
,
'LÀO CAI'
,
'LONG AN'
,
'NAM ĐỊNH'
,
'NGHỆ AN'
,
'NINH BÌNH'
,
'NINH THUẬN'
,
'PHÚ THỌ'
,
'QUẢNG BÌNH'
,
'QUẢNG NAM'
,
'QUẢNG NGÃI'
,
'QUẢNG NINH'
,
'QUẢNG TRỊ'
,
'SÓC TRĂNG'
,
'SƠN LA'
,
'TÂY NINH'
,
'THÁI BÌNH'
,
'THÁI NGUYÊN'
,
'THANH HÓA'
,
'THỪA THIÊN- HUẾ'
,
'TIỀN GIANG'
,
'TRÀ VINH'
,
'TUYÊN QUANG'
,
'VĨNH LONG'
,
'VĨNH PHÚC'
,
'YÊN BÁI'
,
'PHÚ YÊN'
,
'CẦN THƠ'
,
'ĐÀ NẴNG'
,
'HẢI PHÒNG'
,
'HÀ NỘI'
,
'HỒ CHÍ MINH'
,
'KV BẮC TRUNG BỘ'
,
'KV ĐÔNG NAM BỘ'
,
'KV NAM TRUNG BỘ'
,
'KV TÂY NGUYÊN'
]
end
end
end
app/models/job.rb
View file @
a3c73032
...
@@ -8,6 +8,8 @@ class Job < ApplicationRecord
...
@@ -8,6 +8,8 @@ class Job < ApplicationRecord
has_and_belongs_to_many
:cities
has_and_belongs_to_many
:cities
def
self
.
create_new_jobs
(
arr_jobs
)
def
self
.
create_new_jobs
(
arr_jobs
)
viet_nam
=
Country
.
find_or_create_by
(
name:
'Viet Nam'
)
another
=
Country
.
find_or_create_by
(
name:
'another'
)
arr_jobs
.
each
do
|
item
|
arr_jobs
.
each
do
|
item
|
job_cities
=
[]
job_cities
=
[]
city_name
=
[]
city_name
=
[]
...
@@ -32,7 +34,7 @@ class Job < ApplicationRecord
...
@@ -32,7 +34,7 @@ class Job < ApplicationRecord
city_name
=
city_name
-
job_cities
.
pluck
(
:name
)
city_name
=
city_name
-
job_cities
.
pluck
(
:name
)
city_name
.
each
do
|
name
|
city_name
.
each
do
|
name
|
job
.
cities
<<
City
.
create
(
name:
name
)
job
.
cities
<<
City
.
create
(
name:
name
,
country:
City
.
list
.
include?
(
name
.
upcase
)
?
viet_nam
:
another
)
end
end
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