Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_thanhnd
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
3
Merge Requests
3
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
thanhnd
venjob_thanhnd
Commits
5e04a98f
Commit
5e04a98f
authored
May 08, 2020
by
thanhnd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
job detail and history jobs
parent
0ebcc9ac
Pipeline
#605
failed with stages
in 0 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
4 deletions
+57
-4
app/controllers/jobs_controller.rb
+12
-1
app/models/history_job.rb
+5
-0
app/models/job.rb
+1
-0
app/views/jobs/_jobs.html.erb
+2
-1
app/views/jobs/history.html.erb
+34
-0
app/views/layouts/application.html.erb
+1
-1
config/routes.rb
+2
-1
No files found.
app/controllers/jobs_controller.rb
View file @
5e04a98f
class
JobsController
<
ApplicationController
class
JobsController
<
ApplicationController
def
show
def
show
@job_detail
=
Job
.
find_by_id
(
params
[
:id
])
@job_detail
=
Job
.
find_by_id
(
params
[
:id
])
HistoryJob
.
find_or_create_by
(
job_id:
@job_detail
.
id
,
user_id:
current_user
)
if
current_user
HistoryJob
.
find_or_create_by
(
job_id:
@job_detail
.
id
,
user_id:
current_user
.
id
)
end
end
def
history
@historyjobs
=
HistoryJob
.
job_by_id
(
current_user
.
id
)
@hj
=
[]
@historyjobs
.
each
do
|
historyjob
|
@hj
<<
Job
.
find
(
historyjob
.
job_id
)
end
end
end
def
index
def
index
...
...
app/models/history_job.rb
View file @
5e04a98f
class
HistoryJob
<
ApplicationRecord
class
HistoryJob
<
ApplicationRecord
belongs_to
:job
belongs_to
:job
belongs_to
:user
belongs_to
:user
def
self
.
job_by_id
(
user_id
)
select
(
'job_id'
).
where
(
user_id:
user_id
)
end
end
end
\ No newline at end of file
app/models/job.rb
View file @
5e04a98f
class
Job
<
ApplicationRecord
class
Job
<
ApplicationRecord
has_many
:industry_jobs
has_many
:industry_jobs
has_many
:saved_jobs
has_many
:saved_jobs
has_many
:history_jobs
has_many
:applied_jobs
has_many
:applied_jobs
has_and_belongs_to_many
:users
has_and_belongs_to_many
:users
belongs_to
:area
belongs_to
:area
...
...
app/views/jobs/_jobs.html.erb
View file @
5e04a98f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<%
@pagin_job
.
each
do
|
job
|
%>
<%
@pagin_job
.
each
do
|
job
|
%>
<ul>
<ul>
<button
class=
"button2"
>
Favorites
</button>
<button
class=
"button2"
>
Favorites
</button>
<li>
<%=
job
[
'job_name'
]
%>
</li>
<li>
<%=
link_to
job
[
'job_name'
],
job_detail_url
(
job
[
'id'
])
%>
</li>
</ul>
</ul>
<%
end
%>
<%
end
%>
\ No newline at end of file
app/views/jobs/history.html.erb
0 → 100644
View file @
5e04a98f
<div
id=
"search"
class=
"container p-5 my-2 bg-secondary text-white"
>
<!-- Search form -->
<form
class=
"form-inline md-form mr-auto mb-4"
>
<input
class=
"form-control mr-sm-2"
type=
"text"
placeholder=
"Search"
aria-label=
"Search"
>
<button
class=
"btn btn-outline-warning btn-rounded btn-sm my-0"
type=
"submit"
>
Search
</button>
</form>
</div>
<div
id=
"job_hisotry"
class=
"container p-5 my-2 bg-secondary text-white"
>
<%
if
@historyjobs
.
nil?
==
true
%>
<div>
This id is not available.
</div>
<%
else
%>
<font
color=
"red"
><b><label
>
Job History:
</label></b></font>
<ul>
<%
@hj
.
each
do
|
j
|
%>
<li>
<%=
link_to
j
.
job_name
,
job_detail_url
(
j
.
id
)
%>
</li>
<li>
<%=
j
.
salary
%>
</li>
<li>
<%=
j
.
level
%>
</li>
<li>
<%=
j
.
experience
%>
</li>
<li
><span
class=
"text"
>
<%=
j
.
description
%>
</span>
</li>
<br>
<%
end
%>
</ul>
<button
class=
"button button1"
>
Apply
</button>
<button
class=
"button button2"
>
Favorites
</button>
<%
end
%>
</div>
app/views/layouts/application.html.erb
View file @
5e04a98f
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
</li>
</li>
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
><li>
<%=
link_to
'History'
%>
</li></a>
<a
class=
"nav-link"
href=
"#"
><li>
<%=
link_to
'History'
,
history_url
%>
</li></a>
</li>
</li>
</ul>
</ul>
</div>
</div>
...
...
config/routes.rb
View file @
5e04a98f
...
@@ -10,7 +10,8 @@ Rails.application.routes.draw do
...
@@ -10,7 +10,8 @@ Rails.application.routes.draw do
delete
"signout"
=>
"devise/sessions#destroy"
delete
"signout"
=>
"devise/sessions#destroy"
end
end
get
'detail/:id'
,
to:
'jobs#show'
get
'detail/:id'
,
to:
'jobs#show'
,
as: :job_detail
get
'history'
,
to:
'jobs#history'
get
'jobs/search'
=>
'jobs#search'
,
as: :job_search
get
'jobs/search'
=>
'jobs#search'
,
as: :job_search
root
'top_page#index'
root
'top_page#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
...
...
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