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
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xuan Trung Le
venjob
Commits
2ccb6626
Commit
2ccb6626
authored
Nov 02, 2017
by
Xuan Trung Le
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs
parent
4e7d7240
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
14 deletions
+15
-14
app/controllers/applies_controller.rb
+5
-3
app/models/apply_job.rb
+4
-1
app/models/job.rb
+0
-4
app/views/applies/apply.html.erb
+2
-2
app/views/applies/confirm.html.erb
+1
-1
app/views/jobs/show.html.erb
+1
-1
app/views/my_pages/my_job.html.erb
+1
-1
config/routes.rb
+1
-1
No files found.
app/controllers/applies_controller.rb
View file @
2ccb6626
...
@@ -15,13 +15,14 @@ class AppliesController < ApplicationController
...
@@ -15,13 +15,14 @@ class AppliesController < ApplicationController
@application
=
ApplyJob
.
new
(
application_params
)
@application
=
ApplyJob
.
new
(
application_params
)
@application
.
user
=
current_user
@application
.
user
=
current_user
@application
.
job_id
=
session
[
:job_id
]
@application
.
job_id
=
session
[
:job_id
]
session
[
:candidate
]
=
{
name:
application_params
[
:name
],
@application
.
cv
=
current_user
.
cv
if
application_params
[
:cv
].
blank?
session
[
:candidate
]
=
{
name:
application_params
[
:name
],
email:
application_params
[
:email
],
email:
application_params
[
:email
],
cv:
application_params
[
:cv
]
}
cv:
(
application_params
[
:cv
]
||
current_user
.
cv
)
}
unless
@application
.
valid?
unless
@application
.
valid?
flash
[
:error
]
=
@application
.
errors
.
full_messages
.
to_sentence
flash
[
:error
]
=
@application
.
errors
.
full_messages
.
to_sentence
redirect_to
apply_path
(
job_id:
session
[
:job_id
])
redirect_to
apply_
applies_
path
(
job_id:
session
[
:job_id
])
return
return
end
end
end
end
...
@@ -30,6 +31,7 @@ class AppliesController < ApplicationController
...
@@ -30,6 +31,7 @@ class AppliesController < ApplicationController
@application
=
ApplyJob
.
new
(
user:
current_user
,
@application
=
ApplyJob
.
new
(
user:
current_user
,
job_id:
session
[
:job_id
])
job_id:
session
[
:job_id
])
@application
.
attributes
=
session
[
:candidate
]
@application
.
attributes
=
session
[
:candidate
]
@application
.
cv
=
current_user
.
cv
if
@application
.
cv
.
file
.
nil?
if
@application
.
save
if
@application
.
save
flash
[
:notice
]
=
'Congratulation! Job was successfully applied'
flash
[
:notice
]
=
'Congratulation! Job was successfully applied'
...
...
app/models/apply_job.rb
View file @
2ccb6626
class
ApplyJob
<
ApplicationRecord
class
ApplyJob
<
ApplicationRecord
belongs_to
:job
belongs_to
:job
belongs_to
:user
belongs_to
:user
validates
:cv
,
presence:
true
validates
_size_of
:cv
,
maximum:
5
.
megabytes
,
message:
'size should be less than 5MB'
validates
:email
,
presence:
true
validates
:email
,
presence:
true
validates
:name
,
presence:
true
validates
:name
,
presence:
true
# CarrierWave
mount_uploader
:cv
,
CvUploader
end
end
app/models/job.rb
View file @
2ccb6626
...
@@ -66,8 +66,4 @@ class Job < ApplicationRecord
...
@@ -66,8 +66,4 @@ class Job < ApplicationRecord
def
self
.
filter_link_exist
(
links
)
def
self
.
filter_link_exist
(
links
)
links
-
Job
.
where
(
original_link:
links
).
pluck
(
:original_link
)
links
-
Job
.
where
(
original_link:
links
).
pluck
(
:original_link
)
end
end
def
applied_at
(
user_id
)
apply_jobs
.
select
{
|
application
|
application
.
user_id
=
user_id
}.
first
.
created_at
end
end
end
app/views/applies/apply.html.erb
View file @
2ccb6626
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<p
class=
"text-info"
>
1. Apply form
</p>
<p
class=
"text-info"
>
1. Apply form
</p>
</div>
</div>
<div
class=
"form-horizontal"
>
<div
class=
"form-horizontal"
>
<%=
form_for
@application
,
url:
confirm_applies_path
do
|
f
|
%>
<%=
form_for
(
@application
,
url:
confirm_applies_path
,
html:
{
method: :post
,
multipart:
true
})
do
|
f
|
%>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<%=
f
.
label
:Email
,
'Email:'
,
class:
"control-label col-md-2"
%>
<%=
f
.
label
:Email
,
'Email:'
,
class:
"control-label col-md-2"
%>
<div
class=
"col-sm-10"
>
<div
class=
"col-sm-10"
>
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<%=
f
.
label
:cv
,
'Cv:'
,
class:
"control-label col-md-2"
%>
<%=
f
.
label
:cv
,
'Cv:'
,
class:
"control-label col-md-2"
%>
<div
class=
"col-sm-10"
>
<div
class=
"col-sm-10"
>
<label
for=
"apply_job_cv"
>
<%=
@application
.
cv
%>
</label>
<label
for=
"apply_job_cv"
>
<%=
@application
.
cv
.
filename
%>
</label>
<%=
f
.
file_field
:cv
,
class:
"form-control"
%>
<%=
f
.
file_field
:cv
,
class:
"form-control"
%>
</label>
</label>
</div>
</div>
...
...
app/views/applies/confirm.html.erb
View file @
2ccb6626
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<div
class=
"col-md-offset-2 col-md-10"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<p>
Fullname:
<%=
@application
.
name
%>
</p>
<p>
Fullname:
<%=
@application
.
name
%>
</p>
<p>
Email:
<%=
@application
.
email
%>
</p>
<p>
Email:
<%=
@application
.
email
%>
</p>
<p>
Cv:
<%=
@application
.
cv
%>
</p>
<p>
Cv:
<%=
@application
.
cv
.
filename
%>
</p>
<div
class=
"col-md-10"
>
<div
class=
"col-md-10"
>
<%=
button_to
"Edit"
,
<%=
button_to
"Edit"
,
apply_applies_path
(
job_id:
session
[
:job_id
]),
apply_applies_path
(
job_id:
session
[
:job_id
]),
...
...
app/views/jobs/show.html.erb
View file @
2ccb6626
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
<div
class=
"col-md-6"
>
<div
class=
"col-md-6"
>
<%=
button_to
"Favorite"
,
<%=
button_to
"Favorite"
,
job_favorites_path
(
job_id:
@job
.
id
),
job_favorites_path
(
job_id:
@job
.
id
),
class:
"btn btn-primary btn-lg"
%>
class:
"btn btn-primary btn-lg
btn-block
"
%>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
app/views/my_pages/my_job.html.erb
View file @
2ccb6626
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<p>
<p>
<span><strong>
Location:
</strong>
<%=
"
#{
job
.
location
}
"
%>
</span>
<span><strong>
Location:
</strong>
<%=
"
#{
job
.
location
}
"
%>
</span>
<span><strong>
Salary:
</strong>
<%=
job
.
salary
%>
</span>
<span><strong>
Salary:
</strong>
<%=
job
.
salary
%>
</span>
<span
class=
"navbar-right"
><strong>
Applied at:
</strong>
<%=
job
.
applied_at
(
current_user
.
id
)
.
strftime
(
'%m/%d/%y'
)
%>
</span>
<span
class=
"navbar-right"
><strong>
Applied at:
</strong>
<%=
job
.
created_at
.
strftime
(
'%m/%d/%y'
)
%>
</span>
</p>
</p>
</div>
</div>
</div>
</div>
...
...
config/routes.rb
View file @
2ccb6626
...
@@ -36,7 +36,7 @@ Rails.application.routes.draw do
...
@@ -36,7 +36,7 @@ Rails.application.routes.draw do
get
'download'
=>
'my_pages#download_cv'
get
'download'
=>
'my_pages#download_cv'
end
end
end
end
resources
:applies
do
resources
:applies
,
path:
''
,
only:
[]
do
collection
do
collection
do
get
:apply
get
:apply
post
:confirm
post
:confirm
...
...
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