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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
Thanh Hung Pham
veNJOB
Commits
58da1976
Commit
58da1976
authored
Jul 24, 2017
by
Thanh Hung Pham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix comment - Check signed in by controller
parent
45cb0dd9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
14 deletions
+12
-14
app/controllers/jobs_controller.rb
+8
-3
app/views/jobs/favorite.js.erb
+1
-1
app/views/jobs/index.html.erb
+1
-6
app/views/layouts/_header.html.erb
+2
-4
No files found.
app/controllers/jobs_controller.rb
View file @
58da1976
...
...
@@ -52,9 +52,10 @@ class JobsController < ApplicationController
end
def
favorite
@job_id
=
params
[
:job_id
]
job
=
Job
.
find
(
@job_id
)
Favorite
.
new
(
user:
current_user
,
job:
job
).
save
if
Favorite
.
where
(
user:
current_user
,
job:
job
).
blank?
redirect_to
new_user_session_path
unless
user_signed_in?
@job
=
Job
.
find
(
params
[
:job_id
])
Favorite
.
new
(
user:
current_user
,
job:
@job
).
save
if
Favorite
.
where
(
user:
current_user
,
job:
@job
).
blank?
end
def
favorite_remove
...
...
@@ -64,11 +65,15 @@ class JobsController < ApplicationController
end
def
favorited_jobs
redirect_to
new_user_session_path
unless
user_signed_in?
@favorited_jobs
=
Favorite
.
where
(
user:
current_user
)
end
def
history_jobs
redirect_to
new_user_session_path
unless
user_signed_in?
@history_jobs
=
History
.
all
end
end
app/views/jobs/favorite.js.erb
View file @
58da1976
$("#favorite_
<%=
@job
_
id
%>
").remove()
$("#favorite_
<%=
@job
.
id
%>
").remove()
app/views/jobs/index.html.erb
View file @
58da1976
...
...
@@ -36,12 +36,7 @@
<td>
<%
if
Favorite
.
where
(
user:
current_user
,
job:
job
).
blank?
%>
<div
class=
"col-md-3"
id=
"favorite_
<%=
job
.
id
%>
"
>
<%
if
user_signed_in?
%>
<%=
link_to
'Favorite'
,
jobs_favorite_path
(
job_id:
job
.
id
,
format:
'js'
),
remote:
true
,
class:
'favorite_add'
%>
<%
else
%>
<%=
link_to
'Favorite'
,
new_user_session_path
%>
<%
end
%>
<input
type=
"hidden"
id=
"job_id"
name=
"job_id"
value=
"
<%=
job
.
id
%>
"
>
<%=
link_to
'Favorite'
,
jobs_favorite_path
(
job_id:
job
.
id
,
format:
'js'
),
remote:
true
,
class:
'favorite_add'
%>
</div>
<%
end
%>
</td>
...
...
app/views/layouts/_header.html.erb
View file @
58da1976
...
...
@@ -6,14 +6,12 @@
<%
if
user_signed_in?
%>
<li>
<%=
link_to
'My profile'
,
registrations_show_path
%>
</li>
<li>
<%=
link_to
'Log out'
,
destroy_user_session_path
,
method: :delete
%>
</li>
<li>
<%=
link_to
'Favorite'
,
jobs_favorited_jobs_path
%>
</li>
<li>
<%=
link_to
'History'
,
jobs_history_jobs_path
%>
</li>
<%
else
%>
<li>
<%=
link_to
'Login'
,
new_user_session_path
%>
</li>
<li>
<%=
link_to
'Register'
,
new_user_registration_path
%>
</li>
<li>
<%=
link_to
'Favorite'
,
new_user_session_path
%>
</li>
<li>
<%=
link_to
'History'
,
new_user_session_path
%>
</li>
<%
end
%>
<li>
<%=
link_to
'Favorite'
,
jobs_favorited_jobs_path
%>
</li>
<li>
<%=
link_to
'History'
,
jobs_history_jobs_path
%>
</li>
</ul>
</nav>
</div>
...
...
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