Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjobs_app
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
Quang Vinh Nguyen
venjobs_app
Commits
13964180
Commit
13964180
authored
Jun 29, 2018
by
Quang Vinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix job apply controller
parent
0aa0df6d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
25 deletions
+27
-25
app/controllers/entries_controller.rb
+25
-24
app/views/entries/new.html.erb
+2
-1
No files found.
app/controllers/entries_controller.rb
View file @
13964180
...
@@ -24,36 +24,37 @@ class EntriesController < ApplicationController
...
@@ -24,36 +24,37 @@ class EntriesController < ApplicationController
# POST /entries.json
# POST /entries.json
def
create
def
create
@entry
=
Entry
.
new
(
entry_params
)
@entry
=
Entry
.
new
(
entry_params
)
render
:new
and
return
unless
@entry
.
valid?
@job
=
Job
.
find
(
params
[
:job_id
])
@job
=
Job
.
find
(
params
[
:job_id
])
@user
=
User
.
find_by
(
email:
params
[
:entry
][
:entry_email
])
@user
=
User
.
find_by
(
email:
params
[
:entry
][
:entry_email
])
unless
@user
unless
@user
random_password
=
Devise
.
friendly_token
random_password
=
Devise
.
friendly_token
@user
=
User
.
new
(
name:
params
[
:entry
][
:entry_name
],
@user
=
User
.
new
(
name:
params
[
:entry
][
:entry_name
],
email:
params
[
:entry
][
:entry_email
],
email:
params
[
:entry
][
:entry_email
],
phone:
params
[
:entry
][
:entry_phone
],
phone:
params
[
:entry
][
:entry_phone
],
address:
params
[
:entry
][
:entry_address
],
address:
params
[
:entry
][
:entry_address
]
,
password:
random_password
,
password:
random_password
,
password_confirmation:
random_password
)
password_confirmation:
random_password
)
render
:new
and
return
unless
@user
.
valid?
@user
.
skip_confirmation!
@user
.
skip_confirmation!
@user
.
save!
@user
.
save
end
end
@entry
.
user_id
=
@user
.
id
@entry
.
user_id
=
@user
.
id
@entry
.
job_id
=
@job
.
id
@entry
.
job_id
=
@job
.
id
if
@user
.
jobs
.
find_by
(
id:
@job
.
id
)
if
@user
.
jobs
.
find_by
(
id:
@job
.
id
)
redirect_to
job_url
(
@job
),
flash:
{
secondary:
'You has been entry this job.'
}
redirect_to
job_url
(
@job
),
flash:
{
secondary:
'You has been entry this job.'
}
else
if
@entry
.
save
UserMailer
.
job_apply
(
@user
,
@job
).
deliver_now
redirect_to
@entry
,
flash:
{
secondary:
'Thank you for apply. Please check your email.'
}
else
else
render
:new
if
@entry
.
save
UserMailer
.
job_apply
(
@user
,
@job
).
deliver_now
redirect_to
@entry
,
flash:
{
secondary:
'Thank you for apply. Please check your email.'
}
else
render
:new
end
end
end
end
end
end
# PATCH/PUT /entries/1
# PATCH/PUT /entries/1
...
...
app/views/entries/new.html.erb
View file @
13964180
<%
provide
(
:button_text
,
'Apply'
)
%>
<%
provide
(
:button_text
,
'Apply'
)
%>
<%
@job
=
Job
.
find
(
params
[
:job_id
])
%>
<%
@job
=
Job
.
find
(
params
[
:job_id
])
%>
<h3>
Id:
<%=
@job
.
id
%>
--
Job_title:
<%=
@job
.
title
%>
</h3>
<h3>
Job_title:
<%=
@job
.
title
%>
</h3>
<%
provide
(
:job_id
,
@job
.
id
)
%>
<%
provide
(
:job_id
,
@job
.
id
)
%>
<%=
render
'form'
,
entry:
@entry
%>
<%=
render
'form'
,
entry:
@entry
%>
\ 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