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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Nguyen Hoang Mai Phuong
VeNJOB
Commits
cb86cd1d
Commit
cb86cd1d
authored
Aug 05, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change find id to slug
parent
30c1a60e
Pipeline
#1383
canceled with stages
in 0 seconds
Changes
11
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
30 additions
and
10 deletions
+30
-10
app/assets/stylesheets/custom.scss
+1
-1
app/controllers/jobs_controller.rb
+2
-1
app/helpers/application_helper.rb
+3
-0
app/models/job.rb
+7
-0
app/views/jobs/_breadcrumb.html.slim
+0
-0
app/views/jobs/index.html.slim
+2
-2
app/views/jobs/show.html.slim
+2
-2
app/views/top/index.html.slim
+2
-2
config/routes.rb
+2
-1
db/migrate/20210805021856_add_slug_to_jobs.rb
+6
-0
db/schema.rb
+3
-1
No files found.
app/assets/stylesheets/custom.scss
View file @
cb86cd1d
...
...
@@ -58,7 +58,7 @@
}
}
.apply-job
btn
{
.apply-job
.btn
{
align-items
:
center
;
justify-content
:
center
;
}
...
...
app/controllers/jobs_controller.rb
View file @
cb86cd1d
...
...
@@ -14,6 +14,6 @@ class JobsController < ApplicationController
end
def
show
@job
=
Job
.
latest_jobs
.
find_by
(
id:
params
[
:job_id
])
@job
=
Job
.
latest_jobs
.
find_by
(
slug:
params
[
:job_slug
])
end
end
\ No newline at end of file
app/helpers/application_helper.rb
View file @
cb86cd1d
module
ApplicationHelper
def
format_datetime
(
input
)
input
.
strftime
(
'%d/%m/%Y'
)
end
end
app/models/job.rb
View file @
cb86cd1d
class
Job
<
ApplicationRecord
extend
FriendlyId
friendly_id
:title
,
use:
%i[slugged finders]
belongs_to
:company
has_many
:apply_jobs
,
dependent: :destroy
has_many
:favorite_jobs
,
dependent: :destroy
...
...
@@ -7,4 +9,8 @@ class Job < ApplicationRecord
has_and_belongs_to_many
:cities
LATEST_JOB_NUMBER
=
5
scope
:latest_jobs
,
->
{
includes
(
:cities
,
:industries
,
:company
).
order
(
'created_at DESC'
)
}
def
normalize_friendly_id
(
string
)
string
.
to_s
.
to_slug
.
normalize
(
transliterations: :vietnamese
).
to_s
end
end
\ No newline at end of file
app/views/jobs/_breadcrumb.html.slim
View file @
cb86cd1d
app/views/jobs/index.html.slim
View file @
cb86cd1d
...
...
@@ -15,9 +15,9 @@
.row.bg-white
.col-10.p-3.border.card-body.text-dark
h5
.mb-1
=
link_to
job
.
title
,
detail_path
(
job
.
id
)
=
link_to
job
.
title
,
detail_path
(
job
.
slug
)
p
.mb-1
=
link_to
job
.
company
.
name
,
"#"
=
job
.
company
.
name
p
.mb-1
i
.fas.fa-dollar-sign.m-1
|
Lương:
...
...
app/views/jobs/show.html.slim
View file @
cb86cd1d
...
...
@@ -6,7 +6,7 @@
h1
.mb-2
=
@job
.
title
h3
.mb-2
=
link_to
@job
.
company
.
name
,
"#"
=
@job
.
company
.
name
.row
.col
p
.mb-2
...
...
@@ -28,7 +28,7 @@
=
@job
.
experience
p
.mb-2
|
Expired at:
=
@job
.
expired_at
.
strftime
(
"%d/%m/%Y"
)
=
format_datetime
(
@job
.
expired_at
)
h5
.my-3
|
Benefits
p
.mb-2
...
...
app/views/top/index.html.slim
View file @
cb86cd1d
...
...
@@ -11,9 +11,9 @@ h3.p-2
.card.my-3
.card-body.text-dark
h5
.mb-1
=
link_to
job
.
title
,
detail_path
(
job
.
id
)
=
link_to
job
.
title
,
detail_path
(
job
.
slug
)
p
.mb-1
=
link_to
job
.
company
.
name
,
"#"
=
job
.
company
.
name
p
.mb-1
i
.fas.fa-dollar-sign.m-1
|
Lương:
...
...
config/routes.rb
View file @
cb86cd1d
...
...
@@ -4,5 +4,5 @@ Rails.application.routes.draw do
get
'industries'
,
to:
'industries#show'
get
'jobs/city/:city_slug'
,
to:
'jobs#index'
,
as:
'city_slug'
get
'jobs/industry/:industry_slug'
,
to:
'jobs#index'
,
as:
'industry_slug'
get
'detail/:job_
id
'
,
to:
'jobs#show'
,
as:
'detail'
get
'detail/:job_
slug
'
,
to:
'jobs#show'
,
as:
'detail'
end
\ No newline at end of file
db/migrate/20210805021856_add_slug_to_jobs.rb
0 → 100644
View file @
cb86cd1d
class
AddSlugToJobs
<
ActiveRecord
::
Migration
[
6.1
]
def
change
add_column
:jobs
,
:slug
,
:string
add_index
:jobs
,
:slug
,
unique:
true
end
end
db/schema.rb
View file @
cb86cd1d
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2021_0
7_31_111344
)
do
ActiveRecord
::
Schema
.
define
(
version:
2021_0
8_05_021856
)
do
create_table
"apply_jobs"
,
charset:
"utf8mb4"
,
collation:
"utf8mb4_0900_ai_ci"
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
,
null:
false
...
...
@@ -119,7 +119,9 @@ ActiveRecord::Schema.define(version: 2021_07_31_111344) do
t
.
datetime
"expired_at"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
string
"slug"
t
.
index
[
"company_id"
],
name:
"index_jobs_on_company_id"
t
.
index
[
"slug"
],
name:
"index_jobs_on_slug"
,
unique:
true
end
create_table
"regions"
,
charset:
"utf8mb4"
,
collation:
"utf8mb4_0900_ai_ci"
,
force: :cascade
do
|
t
|
...
...
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