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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
14 deletions
+30
-14
app/controllers/apply_jobs_controller.rb
+21
-10
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
class
ApplyJobsController
<
ApplicationController
def
new
def
new
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
return
root_path
unless
job
return
root_path
unless
job
@apply_job
=
if
session
[
:apply_job
].
present?
if
session
[
:apply_job
].
present?
ApplyJob
.
new
(
session
[
:apply_job
])
@apply_job
=
ApplyJob
.
new
(
session
[
:apply_job
])
else
@blob
=
ActiveStorage
::
Blob
.
find
(
session
[
:id
])
ApplyJob
.
new
@apply_job
.
assign_attributes
(
cv:
@blob
)
end
else
@apply_job
.
job_id
=
job
.
id
@apply_job
=
ApplyJob
.
new
end
@apply_job
.
job
=
job
end
end
def
confirm
def
confirm
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
if
@apply_job
.
valid?
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
session
[
:apply_job
]
=
@apply_job
render
:confirm
else
else
render
:new
render
:new
end
end
...
@@ -26,7 +34,8 @@ class ApplyJobsController < ApplicationController
...
@@ -26,7 +34,8 @@ class ApplyJobsController < ApplicationController
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@job
=
Job
.
latest_jobs
.
find
(
apply_params
[
:job_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
ApplyJobMailer
.
with
(
apply_job:
@apply_job
,
job:
@job
).
create_apply
.
deliver_now
flash
.
now
[
:success
]
=
'You have applied successfully'
flash
.
now
[
:success
]
=
'You have applied successfully'
else
else
...
@@ -34,11 +43,12 @@ class ApplyJobsController < ApplicationController
...
@@ -34,11 +43,12 @@ class ApplyJobsController < ApplicationController
redirect_to
root_url
redirect_to
root_url
end
end
session
[
:apply_job
]
=
nil
session
[
:apply_job
]
=
nil
session
[
:id
]
=
nil
end
end
private
private
def
apply_params
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
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
...
@@ -15,9 +15,10 @@ h2.text-center
placeholder:
"Type email..."
,
class:
'form-control'
placeholder:
"Type email..."
,
class:
'form-control'
=
f
.
hidden_field
:email
=
f
.
hidden_field
:email
p
.my-1
p
.my-1
=
f
.
label
:cv
,
"CV"
=
f
.
label
:cv
,
"Your CV"
p
br
=
f
.
file_field
:cv
,
required:
true
,
accept:
"application/pdf"
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
=
f
.
hidden_field
:id
,
value:
@blob
.
id
=
@apply_job
.
cv
.
filename
.span.p-3.text-center
.span.p-3.text-center
=
link_to
"Back"
,
apply_path
(
job_id:
@apply_job
.
job_id
),
class:
"btn btn-primary btn-space"
=
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"
=
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
...
@@ -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'
=
f
.
text_field
:email
,
required:
true
,
length:
{
maximum:
255
},
format:
{
with:
ApplyJob
::
VALID_EMAIL_REGEX
},
placeholder:
"Type email..."
,
class:
'form-control'
p
.my-1
p
.my-1
=
f
.
label
:cv
,
"CV"
=
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"
}
=
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
.span.p-3.text-center
=
f
.
submit
"Confirm"
,
class:
"btn btn-primary"
=
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