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
0
Merge Requests
0
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
Nguyen Ngoc Nghia
VeNJOB
Commits
d7f5a870
Commit
d7f5a870
authored
Jan 17, 2020
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using before_action find_user
parent
9c4f8916
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
app/controllers/jobs_controller.rb
+9
-0
app/models/job.rb
+0
-5
No files found.
app/controllers/jobs_controller.rb
View file @
d7f5a870
class
JobsController
<
ApplicationController
class
JobsController
<
ApplicationController
before_action
:authenticate_user!
,
only:
[
:apply
,
:confirm_apply
,
:finish_apply
]
before_action
:authenticate_user!
,
only:
[
:apply
,
:confirm_apply
,
:finish_apply
]
before_action
:find_user
,
only: :apply_available
def
index
def
index
if
params
[
:city_id
]
if
params
[
:city_id
]
...
@@ -41,9 +42,17 @@ class JobsController < ApplicationController
...
@@ -41,9 +42,17 @@ class JobsController < ApplicationController
end
end
end
end
def
apply_available
user_jobs
.
find_by
(
job_id:
@job_id
,
user_id:
@user
.
id
)
end
private
private
def
confirm_apply_info_params
def
confirm_apply_info_params
params
.
require
(
:confirm_apply_info
).
permit
(
:job_id
,
:first_name
,
:last_name
,
:email
)
params
.
require
(
:confirm_apply_info
).
permit
(
:job_id
,
:first_name
,
:last_name
,
:email
)
end
end
def
find_user
@user
=
User
.
fint_by
(
:id
)
end
end
end
app/models/job.rb
View file @
d7f5a870
...
@@ -43,9 +43,4 @@ class Job < ApplicationRecord
...
@@ -43,9 +43,4 @@ class Job < ApplicationRecord
def
self
.
latest_job
def
self
.
latest_job
@latest_job
||=
order
(
updated_at: :desc
).
take
(
Settings
.
top
.
job
.
limit
)
@latest_job
||=
order
(
updated_at: :desc
).
take
(
Settings
.
top
.
job
.
limit
)
end
end
def
apply_available
user
=
User
.
find_by
(
:id
)
user_jobs
.
find_by
(
job_id:
@job_id
,
user_id:
user
.
id
)
end
end
end
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