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
Huỳnh Thiên Phước
venjob
Commits
55bb5b9b
Commit
55bb5b9b
authored
Aug 27, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creating ID8-9
parent
71b84103
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
2 deletions
+40
-2
app/controllers/job_favorites_controller.rb
+21
-0
app/models/user.rb
+13
-1
app/views/layouts/_show_job.html.erb
+3
-1
config/routes.rb
+3
-0
No files found.
app/controllers/job_favorites_controller.rb
0 → 100644
View file @
55bb5b9b
class
JobFavoritesController
<
ApplicationController
before_action
:sign_in_validation
,
only:
[
:create
,
:destroy
]
before_action
:find_job_id
,
only:
[
:new
]
def
create
end
def
destroy
end
private
def
sign_in_validation
return
if
signed_in?
store_location
flash
[
:warning
]
=
Settings
.
user
.
warning_signin
redirect_to
login_path
end
end
app/models/user.rb
View file @
55bb5b9b
...
@@ -3,7 +3,7 @@ class User < ApplicationRecord
...
@@ -3,7 +3,7 @@ class User < ApplicationRecord
before_create
:create_remember_token
before_create
:create_remember_token
mount_uploader
:cv_user
,
UserCvUploader
mount_uploader
:cv_user
,
UserCvUploader
has_many
:favorite_jobs
has_many
:favorite_jobs
,
foreign_key:
"job_id"
,
dependent: :destroy
has_many
:jobs
,
through: :favorite_jobs
has_many
:jobs
,
through: :favorite_jobs
has_many
:job_applieds
has_many
:job_applieds
has_many
:jobs
,
through: :job_applieds
has_many
:jobs
,
through: :job_applieds
...
@@ -20,6 +20,18 @@ class User < ApplicationRecord
...
@@ -20,6 +20,18 @@ class User < ApplicationRecord
PASSWORD_FORMAT
=
/\A(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/x
PASSWORD_FORMAT
=
/\A(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/x
validates
:password
,
format:
{
with:
PASSWORD_FORMAT
,
message:
"is too short or not strength"
}
validates
:password
,
format:
{
with:
PASSWORD_FORMAT
,
message:
"is too short or not strength"
}
def
following?
(
job_id
)
favorite_jobs
.
find_by
(
job_id:
job_id
)
end
def
follow!
(
job_id
)
favorite_jobs
.
create!
(
job_id:
job_id
)
end
def
unfollow!
(
job_id
)
favorite_jobs
.
find_by
(
job_id:
job_id
).
destroy
end
def
self
.
new_remember_token
def
self
.
new_remember_token
SecureRandom
.
urlsafe_base64
SecureRandom
.
urlsafe_base64
end
end
...
...
app/views/layouts/_show_job.html.erb
View file @
55bb5b9b
...
@@ -17,7 +17,9 @@
...
@@ -17,7 +17,9 @@
<%=
link_to
'Read more..'
,
job_detail_path
(
job
.
id
)
%>
<%=
link_to
'Read more..'
,
job_detail_path
(
job
.
id
)
%>
</div>
</div>
</div>
</div>
<button
type=
"button"
class=
"btn btn-primary"
id=
"button-follow"
>
♥ Follow
</button>
<%=
link_to
follow_job_path
(
job
.
id
)
do
%>
<button
type=
"button"
class=
"btn btn-primary"
id=
"button-follow"
>
♥ Follow
</button>
<%
end
%>
</div>
</div>
</div>
</div>
<br>
<br>
...
...
config/routes.rb
View file @
55bb5b9b
...
@@ -33,6 +33,9 @@ Rails.application.routes.draw do
...
@@ -33,6 +33,9 @@ Rails.application.routes.draw do
get
'jobs/industry/:converted_name'
,
to:
'jobs#industry_jobs'
,
as: :industry_jobs
get
'jobs/industry/:converted_name'
,
to:
'jobs#industry_jobs'
,
as: :industry_jobs
get
'jobs/company/:converted_name'
,
to:
'jobs#company_jobs'
,
as: :company_jobs
get
'jobs/company/:converted_name'
,
to:
'jobs#company_jobs'
,
as: :company_jobs
post
'follow_job'
,
to:
'job_favorites#create'
,
as: :follow_job
resources
:job_favorites
,
only:
[
:create
,
:destroy
]
resources
:job_applieds
,
only:
[
:new
,
:create
]
resources
:job_applieds
,
only:
[
:new
,
:create
]
resources
:reset_passwords
,
only:
[
:edit
,
:update
]
resources
:reset_passwords
,
only:
[
:edit
,
:update
]
resources
:confirmations
,
only:
[
:new
]
resources
:confirmations
,
only:
[
:new
]
...
...
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