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
8c905bbe
Commit
8c905bbe
authored
Mar 05, 2020
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetch necessary information
parent
55f7c946
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
8 deletions
+9
-8
app/controllers/users/admins_controller.rb
+3
-2
app/helpers/job_helper.rb
+1
-5
app/models/user.rb
+4
-0
app/views/users/admins/index.html.erb
+1
-1
No files found.
app/controllers/users/admins_controller.rb
View file @
8c905bbe
...
...
@@ -16,9 +16,10 @@ class Users::AdminsController < ApplicationController
user
=
User
.
find_by
(
email:
params
[
:search_user
])
return
redirect_to
users_admin_path
,
notice:
"User/job not found!"
if
user
.
blank?
user
.
jobs
applied_jobs
=
user
.
jobs
applied_jobs
.
page
(
params
[
:page
]).
per
(
Settings
.
job
.
per_page
)
else
UserJob
.
where
.
not
(
applied_at:
nil
).
collect
{
|
uj
|
uj
.
job
}
Job
.
joins
(
:user_jobs
).
where
.
not
(
user_jobs:
{
applied_at:
nil
}).
distinct
end
end
end
app/helpers/job_helper.rb
View file @
8c905bbe
...
...
@@ -5,10 +5,6 @@ module JobHelper
end
def
job_applied_at
(
job
)
job
.
user_jobs
[
0
].
applied_at
end
def
get_all_user
User
.
all
job
.
user_jobs
.
find_by
(
user_id:
current_user
.
id
).
applied_at
end
end
app/models/user.rb
View file @
8c905bbe
...
...
@@ -35,4 +35,8 @@ class User < ApplicationRecord
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:validatable
def
self
.
list_emails
@emails
||=
self
.
all
.
pluck
(
:email
)
end
end
app/views/users/admins/index.html.erb
View file @
8c905bbe
<h4>
Search user's applied jobs:
</h4>
<%=
form_tag
(
users_admin_path
,
method: :get
)
do
|
f
|
%>
<%=
select_tag
:search_user
,
options_f
rom_collection_for_select
(
get_all_user
,
"email"
,
"email"
,
params
[
:search_user
]),
include_blank:
"Choose user's email"
%>
<%=
select_tag
:search_user
,
options_f
or_select
(
User
.
list_emails
,
params
[
:search_user
]),
include_blank:
"Choose user's email"
%>
<%=
submit_tag
"Search"
%>
<%
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