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
a03072fc
Commit
a03072fc
authored
May 11, 2020
by
thanhnd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add favorites job with button
parent
5e04a98f
Pipeline
#607
canceled with stages
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
4 deletions
+51
-4
app/controllers/jobs_controller.rb
+10
-0
app/models/saved_job.rb
+4
-0
app/views/jobs/favorites.html.erb
+31
-0
app/views/jobs/history.html.erb
+0
-3
app/views/jobs/show.html.erb
+5
-1
config/routes.rb
+1
-0
No files found.
app/controllers/jobs_controller.rb
View file @
a03072fc
...
@@ -3,6 +3,7 @@ class JobsController < ApplicationController
...
@@ -3,6 +3,7 @@ class JobsController < ApplicationController
@job_detail
=
Job
.
find_by_id
(
params
[
:id
])
@job_detail
=
Job
.
find_by_id
(
params
[
:id
])
if
current_user
if
current_user
HistoryJob
.
find_or_create_by
(
job_id:
@job_detail
.
id
,
user_id:
current_user
.
id
)
HistoryJob
.
find_or_create_by
(
job_id:
@job_detail
.
id
,
user_id:
current_user
.
id
)
SavedJob
.
find_or_create_by
(
job_id:
@job_detail
.
id
,
user_id:
current_user
.
id
)
end
end
end
end
...
@@ -15,6 +16,15 @@ class JobsController < ApplicationController
...
@@ -15,6 +16,15 @@ class JobsController < ApplicationController
end
end
end
end
def
favorites
@favjobs
=
SavedJob
.
job_by_id
(
current_user
.
id
)
@fj
=
[]
@favjobs
.
each
do
|
favjob
|
@fj
<<
Job
.
find
(
favjob
.
job_id
)
end
end
def
index
def
index
@job_count
=
Job
.
count
@job_count
=
Job
.
count
pagin
=
params
[
:page
].
to_i
>
0
?
params
[:
page
].
to_i
:
1
pagin
=
params
[
:page
].
to_i
>
0
?
params
[:
page
].
to_i
:
1
...
...
app/models/saved_job.rb
View file @
a03072fc
class
SavedJob
<
ApplicationRecord
class
SavedJob
<
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
app/views/jobs/favorites.html.erb
0 → 100644
View file @
a03072fc
<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_favorites"
class=
"container p-5 my-2 bg-secondary text-white"
>
<%
if
@favjobs
.
nil?
==
true
%>
<div>
This id is not available.
</div>
<%
else
%>
<font
color=
"red"
><b><label
>
Favorites - Job :
</label></b></font>
<ul>
<%
@fj
.
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>
<%
end
%>
</div>
app/views/jobs/history.html.erb
View file @
a03072fc
...
@@ -24,9 +24,6 @@
...
@@ -24,9 +24,6 @@
<br>
<br>
<%
end
%>
<%
end
%>
</ul>
</ul>
<button
class=
"button button1"
>
Apply
</button>
<button
class=
"button button2"
>
Favorites
</button>
<%
end
%>
<%
end
%>
</div>
</div>
...
...
app/views/jobs/show.html.erb
View file @
a03072fc
...
@@ -28,7 +28,11 @@
...
@@ -28,7 +28,11 @@
<li
><span
class=
"text"
>
<%=
@job_detail
.
description
%>
</span>
<li
><span
class=
"text"
>
<%=
@job_detail
.
description
%>
</span>
</li>
</li>
</ul>
</ul>
<button
class=
"button button1"
>
Apply
</button>
<%=
link_to
'/detail/:id'
,
remote:
true
do
%>
<button
class=
"button button1"
>
Apply
</button>
<%
end
%>
<button
class=
"button button2"
>
Favorites
</button>
<button
class=
"button button2"
>
Favorites
</button>
<%
end
%>
<%
end
%>
</div>
</div>
...
...
config/routes.rb
View file @
a03072fc
...
@@ -12,6 +12,7 @@ Rails.application.routes.draw do
...
@@ -12,6 +12,7 @@ Rails.application.routes.draw do
get
'detail/:id'
,
to:
'jobs#show'
,
as: :job_detail
get
'detail/:id'
,
to:
'jobs#show'
,
as: :job_detail
get
'history'
,
to:
'jobs#history'
get
'history'
,
to:
'jobs#history'
get
'favorites'
,
to:
'jobs#favorites'
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