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
104ff770
Commit
104ff770
authored
Aug 16, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store-file-cv
parent
8ca02714
Pipeline
#1392
canceled with stages
in 0 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
11 deletions
+27
-11
app/controllers/apply_jobs_controller.rb
+18
-7
app/views/apply_jobs/confirm.html.slim
+5
-3
app/views/apply_jobs/new.html.slim
+4
-1
No files found.
app/controllers/apply_jobs_controller.rb
View file @
104ff770
class
ApplyJobsController
<
ApplicationController
def
new
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
return
root_path
unless
job
@apply_job
=
if
session
[
:apply_job
].
present?
ApplyJob
.
new
(
session
[
:apply_job
])
if
session
[
:apply_job
].
present?
@apply_job
=
ApplyJob
.
new
(
session
[
:apply_job
])
@blob
=
ActiveStorage
::
Blob
.
find
(
session
[
:id
])
@apply_job
.
assign_attributes
(
cv:
@blob
)
else
ApplyJob
.
new
@apply_job
=
ApplyJob
.
new
end
@apply_job
.
job
_id
=
job
.
id
@apply_job
.
job
=
job
end
def
confirm
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
if
@apply_job
.
valid?
@blob
=
ActiveStorage
::
Blob
.
create_and_upload!
(
io:
apply_params
[
:cv
],
filename:
apply_params
[
:cv
].
original_filename
,
content_type:
apply_params
[
:cv
].
content_type
)
session
[
:id
]
=
@blob
.
id
session
[
:apply_job
]
=
@apply_job
render
:confirm
else
render
:new
end
...
...
@@ -26,7 +34,8 @@ class ApplyJobsController < ApplicationController
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@job
=
Job
.
latest_jobs
.
find
(
apply_params
[
:job_id
])
if
@apply_job
.
save
@apply_job
.
cv
=
ActiveStorage
::
Blob
.
find
(
session
[
:id
])
if
@apply_job
.
save!
ApplyJobMailer
.
with
(
apply_job:
@apply_job
,
job:
@job
).
create_apply
.
deliver_now
flash
.
now
[
:success
]
=
'You have applied successfully'
else
...
...
@@ -34,11 +43,12 @@ class ApplyJobsController < ApplicationController
redirect_to
root_url
end
session
[
:apply_job
]
=
nil
session
[
:id
]
=
nil
end
private
def
apply_params
params
.
require
(
:apply_job
).
permit
(
:name
,
:email
,
:cv
,
:job_id
)
params
.
require
(
:apply_job
).
permit
(
:name
,
:email
,
:cv
,
:job_id
,
:id
)
end
end
\ No newline at end of file
app/views/apply_jobs/confirm.html.slim
View file @
104ff770
...
...
@@ -15,9 +15,10 @@ h2.text-center
placeholder:
"Type email..."
,
class:
'form-control'
=
f
.
hidden_field
:email
p
.my-1
=
f
.
label
:cv
,
"CV"
p
=
f
.
file_field
:cv
,
required:
true
,
accept:
"application/pdf"
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
=
f
.
label
:cv
,
"Your CV"
br
=
f
.
hidden_field
:id
,
value:
@blob
.
id
=
@apply_job
.
cv
.
filename
.span.p-3.text-center
=
link_to
"Back"
,
apply_path
(
job_id:
@apply_job
.
job_id
),
class:
"btn btn-primary btn-space"
=
f
.
submit
"Done"
,
class:
"btn btn-primary btn-space"
\ No newline at end of file
app/views/apply_jobs/new.html.slim
View file @
104ff770
...
...
@@ -12,7 +12,9 @@ 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"
p
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"
}
.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