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
70f021b1
Commit
70f021b1
authored
Jun 25, 2018
by
Quang Vinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
job apply feature
parent
f5664c95
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
19 deletions
+29
-19
app/controllers/entries_controller.rb
+14
-8
app/views/entries/_form.html.erb
+5
-5
app/views/entries/edit.html.erb
+0
-3
app/views/entries/show.html.erb
+2
-2
app/views/jobs/show.html.erb
+8
-1
config/routes.rb
+0
-0
No files found.
app/controllers/entries_controller.rb
View file @
70f021b1
# frozen_string_literal: true
class
EntriesController
<
ApplicationController
class
EntriesController
<
ApplicationController
before_action
:set_entry
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
before_action
:set_entry
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
...
@@ -9,17 +11,19 @@ class EntriesController < ApplicationController
...
@@ -9,17 +11,19 @@ class EntriesController < ApplicationController
# GET /entries/1
# GET /entries/1
# GET /entries/1.json
# GET /entries/1.json
def
show
def
show
;
end
end
# GET /entries/new
# GET /entries/new
def
new
def
new
if
params
[
:entry_name
].
blank?
&&
params
[
:entry_email
]
@entry
=
Entry
.
new
@entry
=
Entry
.
new
else
@entry
=
Entry
.
new
(
entry_name:
params
[
:entry_name
],
entry_email:
params
[
:entry_email
])
end
end
end
# GET /entries/1/edit
# GET /entries/1/edit
def
edit
def
edit
;
end
end
# POST /entries
# POST /entries
# POST /entries.json
# POST /entries.json
...
@@ -28,8 +32,8 @@ class EntriesController < ApplicationController
...
@@ -28,8 +32,8 @@ class EntriesController < ApplicationController
@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
])
||
User
.
create
(
name:
params
[
:entry
][
:entry_name
],
User
.
create
(
name:
params
[
:entry
][
:entry_name
],
email:
params
[
:entry
][
:entry_email
],
email:
params
[
:entry
][
:entry_email
],
password:
'password'
,
password:
'password'
,
password_confirmation:
'password'
)
password_confirmation:
'password'
)
...
@@ -38,11 +42,12 @@ class EntriesController < ApplicationController
...
@@ -38,11 +42,12 @@ class EntriesController < ApplicationController
@entry
.
job_id
=
@job
.
id
@entry
.
job_id
=
@job
.
id
if
@user
.
jobs
.
include?
(
@job
)
if
@user
.
jobs
.
include?
(
@job
)
redirect_to
job_url
(
@job
),
notice:
'You has been entry this job.'
# redirect_to job_url(@job), notice: 'You has been entry this job.'
redirect_to
job_url
(
@job
),
flash:
{
secondary:
'You has been entry this job.'
}
elsif
elsif
if
@entry
.
save
if
@entry
.
save
UserMailer
.
job_apply
(
@user
,
@job
).
deliver_now
UserMailer
.
job_apply
(
@user
,
@job
).
deliver_now
redirect_to
@entry
,
notice:
'Email sent to you, Thank you for apply.'
redirect_to
@entry
,
flash:
{
secondary:
'Thank you for apply. Please check your email.'
}
else
else
render
:new
render
:new
end
end
...
@@ -67,6 +72,7 @@ class EntriesController < ApplicationController
...
@@ -67,6 +72,7 @@ class EntriesController < ApplicationController
end
end
private
private
# Use callbacks to share common setup or constraints between actions.
# Use callbacks to share common setup or constraints between actions.
def
set_entry
def
set_entry
@entry
=
Entry
.
find
(
params
[
:id
])
@entry
=
Entry
.
find
(
params
[
:id
])
...
...
app/views/entries/_form.html.erb
View file @
70f021b1
<%=
form_with
(
model:
entry
,
local:
true
)
do
|
form
|
%>
<%=
form_with
(
model:
entry
,
local:
true
)
do
|
form
|
%>
<%
if
entry
.
errors
.
any?
%>
<%
if
entry
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<div
id=
"error_explanation"
>
<h
2>
<%=
pluralize
(
entry
.
errors
.
count
,
"error"
)
%>
prohibited this entry from being saved:
</h2
>
<h
5>
<%=
pluralize
(
entry
.
errors
.
count
,
"error"
)
%>
prohibited this entry from being saved:
</h5
>
<ul>
<ul>
<%
entry
.
errors
.
full_messages
.
each
do
|
message
|
%>
<%
entry
.
errors
.
full_messages
.
each
do
|
message
|
%>
...
@@ -14,11 +14,11 @@
...
@@ -14,11 +14,11 @@
<%=
hidden_field_tag
:job_id
,
@job
.
id
%>
<%=
hidden_field_tag
:job_id
,
@job
.
id
%>
<%=
form
.
label
:name
%>
<br>
<%=
form
.
label
:name
%>
<br>
<%=
form
.
text_field
:entry_name
,
class:
'form-control'
%>
<br>
<%=
form
.
text_field
:entry_name
,
class:
'form-control
col-sm-4
'
%>
<br>
<%=
form
.
label
:email
%>
<br>
<%=
form
.
label
:email
%>
<br>
<%=
form
.
email_field
:entry_email
,
class:
'form-control'
%>
<br>
<%=
form
.
email_field
:entry_email
,
class:
'form-control col-sm-4'
%>
<br>
<%=
form
.
submit
yield
(
:button_text
),
class:
"btn btn-primary"
%>
<%=
form
.
submit
yield
(
:button_text
),
class:
"btn btn-secondary"
%>
<%=
link_to
'Back'
,
:back
,
class:
"btn btn-secondary"
%>
<%
end
%>
<%
end
%>
app/views/entries/edit.html.erb
View file @
70f021b1
...
@@ -3,6 +3,3 @@
...
@@ -3,6 +3,3 @@
<h1>
Editing Entry
</h1>
<h1>
Editing Entry
</h1>
<%=
render
'form'
,
entry:
@entry
%>
<%=
render
'form'
,
entry:
@entry
%>
<%=
link_to
'Show'
,
@entry
%>
|
<%=
link_to
'Back'
,
entries_path
%>
app/views/entries/show.html.erb
View file @
70f021b1
...
@@ -11,5 +11,5 @@
...
@@ -11,5 +11,5 @@
<%=
@entry
.
entry_email
%>
<%=
@entry
.
entry_email
%>
</p>
</p>
<%=
link_to
'Edit'
,
edit_entry_path
(
id:
@entry
.
id
)
%>
|
<%=
link_to
'Edit'
,
edit_entry_path
(
id:
@entry
.
id
)
,
class:
"btn btn-secondary"
%>
<%=
link_to
'Back'
,
entries_path
%>
<%=
link_to
'Back'
,
job_path
(
@job
),
class:
"btn btn-secondary"
%>
app/views/jobs/show.html.erb
View file @
70f021b1
...
@@ -11,9 +11,16 @@
...
@@ -11,9 +11,16 @@
<%=
@job
.
description
%>
<%=
@job
.
description
%>
</p>
</p>
<%
if
user_signed_in?
%>
<%=
link_to
"Apply"
,
{
controller:
"entries"
,
action:
"new"
,
job_id:
@job
.
id
,
entry_name:
current_user
.
name
,
entry_email:
current_user
.
email
},
class:
"btn btn-secondary"
%>
<%
else
%>
<%=
link_to
"Apply"
,
apply_path
(
job_id:
@job
.
id
),
<%=
link_to
"Apply"
,
apply_path
(
job_id:
@job
.
id
),
class:
"btn btn-primary"
%>
class:
"btn btn-secondary"
%>
<%
end
%>
<%=
link_to
'Back'
,
:back
,
class:
"btn btn-secondary"
%>
</section>
</section>
</aside>
</aside>
</div>
</div>
config/routes.rb
View file @
70f021b1
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