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
1
Merge Requests
1
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
Tô Ngọc Ánh
VeNJob
Commits
831d463f
Commit
831d463f
authored
Aug 06, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix slug
parent
84915250
Pipeline
#826
failed with stages
in 0 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
7 deletions
+8
-7
app/models/industry.rb
+2
-2
app/models/job.rb
+1
-0
app/models/location.rb
+2
-2
app/views/jobs/_job.html.erb
+1
-1
lib/tasks/create_slug.rake
+2
-2
No files found.
app/models/industry.rb
View file @
831d463f
...
...
@@ -8,11 +8,11 @@ class Industry < ApplicationRecord
has_and_belongs_to_many
:jobs
before_save
:add_slug
before_save
:add_slug
,
unless: :slug
private
def
add_slug
self
.
slug
=
"
#{
self
.
id
}
-
#{
self
.
to_slug
(
self
.
name
)
}
"
self
.
slug
=
"
#{
self
.
to_slug
(
self
.
name
)
}
-
#{
Time
.
now
.
to_i
}#{
rand
(
10000
)
}
"
end
end
app/models/job.rb
View file @
831d463f
class
Job
<
ApplicationRecord
NUMBER_LATEST_JOB
=
6
WORDS_SHORT_DESCRIPTION
=
250
belongs_to
:company
has_many
:applied_jobs
...
...
app/models/location.rb
View file @
831d463f
...
...
@@ -13,11 +13,11 @@ class Location < ApplicationRecord
has_many
:locations_jobs
has_many
:jobs
,
through: :locations_jobs
before_save
:add_slug
before_save
:add_slug
,
unless: :slug
private
def
add_slug
self
.
slug
=
"
#{
self
.
id
}
-
#{
self
.
to_slug
(
self
.
city
)
}
"
self
.
slug
=
"
#{
self
.
to_slug
(
self
.
city
)
}
-
#{
Time
.
now
.
to_i
}#{
rand
(
10000
)
}
"
end
end
app/views/jobs/_job.html.erb
View file @
831d463f
...
...
@@ -9,7 +9,7 @@
<%
end
%>
</p>
<p><strong>
Salary:
</strong>
<%=
job
.
salary
%>
</p>
<p
class=
'card-text'
>
<%=
strip_tags
(
job
.
description
).
truncate
(
250
)
%>
</p>
<p
class=
'card-text'
>
<%=
strip_tags
(
job
.
description
).
truncate
(
Job
::
WORDS_SHORT_DESCRIPTION
)
%>
</p>
</div>
<div
class=
'btn-favorite p-2'
>
<%=
link_to
'Favorite'
,
'#'
,
class:
'btn btn-outline-danger btn-lg'
%>
...
...
lib/tasks/create_slug.rake
View file @
831d463f
...
...
@@ -2,14 +2,14 @@ namespace :create_slug do
desc
'Create slug model Location'
task
locations: :environment
do
Location
.
all
.
each
do
|
location
|
location
.
update_attributes
(
slug:
""
)
location
.
update_attributes
(
slug:
"
#{
location
.
to_slug
(
location
.
city
)
}
-
#{
Time
.
now
.
to_i
}#{
rand
(
10000
)
}
"
)
end
end
desc
'Create slug model Industry'
task
industries: :environment
do
Industry
.
all
.
each
do
|
industry
|
industry
.
update_attributes
(
slug:
""
)
industry
.
update_attributes
(
slug:
"
#{
industry
.
to_slug
(
industry
.
name
)
}
-
#{
Time
.
now
.
to_i
}#{
rand
(
10000
)
}
"
)
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