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
bc2c5d35
Commit
bc2c5d35
authored
Aug 17, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix-store-cv-when-back-to-new
parent
1bf09fb6
Pipeline
#1395
failed with stages
in 0 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
12 deletions
+36
-12
app/assets/stylesheets/custom.scss
+8
-1
app/controllers/apply_jobs_controller.rb
+14
-7
app/helpers/application_helper.rb
+10
-0
app/models/industry.rb
+2
-2
app/views/apply_jobs/new.html.slim
+2
-2
No files found.
app/assets/stylesheets/custom.scss
View file @
bc2c5d35
...
...
@@ -7,9 +7,16 @@
padding-top
:
10px
;
padding-bottom
:
10px
;
}
body
{
position
:
relative
;
padding-bottom
:
228px
;
min-height
:
100vh
;
}
footer
{
min-height
:
227px
;
position
:absolute
;
bottom
:
0
;
width
:
100%
;
}
.navbar
ul
li
a
{
...
...
app/controllers/apply_jobs_controller.rb
View file @
bc2c5d35
class
ApplyJobsController
<
ApplicationController
include
ApplicationHelper
def
new
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
return
root_path
unless
job
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
or
not_found
if
session
[
:apply_job
].
present?
@apply_job
=
ApplyJob
.
new
(
session
[
:apply_job
])
...
...
@@ -19,17 +18,25 @@ class ApplyJobsController < ApplicationController
def
confirm
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
if
@apply_job
.
valid?
@apply_job
.
validate
if
@apply_job
.
cv
.
attached?
&&
@apply_job
.
errors
[
:cv
].
empty?
@blob
=
ActiveStorage
::
Blob
.
create_and_upload!
(
io:
apply_params
[
:cv
],
filename:
apply_params
[
:cv
].
original_filename
,
content_type:
apply_params
[
:cv
].
content_type
)
session
[
:blob_id
]
=
@blob
.
id
elsif
@apply_job
.
cv
.
attached?
&&
!
@apply_job
.
errors
[
:cv
].
empty?
&&
session
[
:blob_id
]
ActiveStorage
::
Blob
.
find_by
(
id:
session
[
:blob_id
]).
try
(
:destroy
)
elsif
!
@apply_job
.
cv
.
attached?
&&
session
[
:blob_id
]
@blob
=
ActiveStorage
::
Blob
.
find_by
(
id:
session
[
:blob_id
])
@apply_job
.
assign_attributes
(
cv:
@blob
)
end
if
@apply_job
.
valid?
session
[
:apply_job
]
=
@apply_job
else
render
:new
return
render
:confirm
end
render
:new
end
def
done
...
...
@@ -41,7 +48,7 @@ class ApplyJobsController < ApplicationController
ApplyJobMailer
.
with
(
apply_job:
@apply_job
,
job:
@job
).
create_apply
.
deliver_now
flash
.
now
[
:success
]
=
'You have applied successfully'
else
flash
.
now
[
:danger
]
=
'
Please apply again'
flash
[
:danger
]
=
'Have something wrong.
Please apply again'
redirect_to
root_url
end
session
[
:apply_job
]
=
nil
...
...
app/helpers/application_helper.rb
View file @
bc2c5d35
...
...
@@ -14,4 +14,14 @@ module ApplicationHelper
def
current_page?
(
*
paths
)
paths
.
include?
(
request
.
path
)
end
def
not_found
raise
ActionController
::
RoutingError
.
new
(
'Not Found'
)
rescue
render_404
end
def
render_404
render
file:
"
#{
Rails
.
root
}
/public/404.html"
,
status: :not_found
end
end
app/models/industry.rb
View file @
bc2c5d35
...
...
@@ -4,8 +4,8 @@ class Industry < ApplicationRecord
has_and_belongs_to_many
:jobs
LATEST_INDUSTRY_NUMBER
=
9
scope
:top_industries
,
->
{
group
(
:name
,
:slug
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_INDUSTRY_NUMBER
)
}
scope
:industry_list
,
->
{
group
(
:name
,
:slug
).
having
(
'count_all >= ?'
,
1
).
order
(
'count_all DESC'
).
count
}
scope
:top_industries
,
->
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_INDUSTRY_NUMBER
)
}
scope
:industry_list
,
->
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
having
(
'count_all >= ?'
,
1
).
order
(
'count_all DESC'
).
count
}
def
normalize_friendly_id
(
string
)
string
.
to_s
.
to_slug
.
normalize
(
transliterations: :vietnamese
).
to_s
...
...
app/views/apply_jobs/new.html.slim
View file @
bc2c5d35
...
...
@@ -12,9 +12,8 @@ h2.text-center.form-title
=
f
.
text_field
:email
,
required:
true
,
length:
{
maximum:
255
},
format:
{
with:
ApplyJob
::
VALID_EMAIL_REGEX
},
placeholder:
"Type email..."
,
class:
'form-control'
p
.my-1
=
f
.
label
:cv
,
"CV"
br
=
@apply_job
.
cv
.
filename
br
=
f
.
file_field
:cv
,
required:
true
,
accept:
"application/pdf"
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
=
f
.
file_field
:cv
,
accept:
"application/pdf"
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
.span.p-3.text-center
=
f
.
submit
"Confirm"
,
class:
"btn btn-primary"
\ No newline at end of file
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